Skip to content

Commit 3da511f

Browse files
committed
Add test on MVM's getAccumulatedDistributionPercentage
Most importantly it verifies that it throws once its lifetime is over
1 parent 581b13b commit 3da511f

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/MarketValidationMechanism.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,40 @@ contract('Market validation Mechanism', function(accounts) {
152152
assert.equal(0, await mvm.getCurrentPeriodIndex.call());
153153
});
154154

155+
it('can call getAccumulatedDistributionPercentage only before it has finished', async function() {
156+
const token = await LifToken.new({from: accounts[0]}),
157+
start = latestTime() + 10,
158+
mvm = await LifMarketValidationMechanism.new(token.address, start,
159+
100, 24, accounts[1], {from: accounts[0]});
160+
161+
await mvm.calculateDistributionPeriods();
162+
163+
try {
164+
await mvm.getAccumulatedDistributionPercentage.call();
165+
assert(false, 'should have thrown because we are before MVM start timestamp');
166+
} catch(e) {
167+
assert(help.isInvalidOpcodeEx(e));
168+
}
169+
170+
await increaseTimeTestRPCTo(start);
171+
assert.equal(0, parseInt(await mvm.getAccumulatedDistributionPercentage.call()));
172+
173+
await increaseTimeTestRPCTo(start + 100);
174+
// 18 comes from distributionDeltas in next test, also 99 in next assertion
175+
assert.equal(18, parseInt(await mvm.getAccumulatedDistributionPercentage.call()));
176+
177+
await increaseTimeTestRPCTo(start + 200);
178+
assert.equal(18 + 99, parseInt(await mvm.getAccumulatedDistributionPercentage.call()));
179+
180+
await increaseTimeTestRPCTo(start + 100 * 24);
181+
try {
182+
await mvm.getAccumulatedDistributionPercentage.call();
183+
assert(false, 'should have thrown because we are past the MVM lifetime');
184+
} catch(e) {
185+
assert(help.isInvalidOpcodeEx(e));
186+
}
187+
});
188+
155189
it('Create 24 months MM', async function() {
156190
const mmInitialBalance = 20000000;
157191
const totalTokenSupply = 100;

0 commit comments

Comments
 (0)