Skip to content

Commit 92fc1d2

Browse files
committed
Add test on MVM's sendTokens
Verifies that it throws when tokens == 0
1 parent 5243843 commit 92fc1d2

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/MarketValidationMechanism.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,35 @@ contract('Market validation Mechanism', function(accounts) {
186186
}
187187
});
188188

189+
it('can send tokens, but throws when tokens == 0', async function() {
190+
const token = await LifToken.new({from: accounts[0]}),
191+
start = latestTime() + 5,
192+
mvm = await LifMarketValidationMechanism.new(token.address, start,
193+
100, 24, accounts[1], {from: accounts[0]});
194+
195+
// mint some tokens, fund fails otherwise b/c it divides weiSent with tokenSupply
196+
await token.mint(accounts[5], 100, {from: accounts[0]});
197+
await mvm.fund({value: 100, from: accounts[0]}); // it just works
198+
await mvm.calculateDistributionPeriods();
199+
200+
await increaseTimeTestRPCTo(start);
201+
202+
await token.approve(mvm.address, 100, {from: accounts[5]});
203+
204+
try {
205+
await mvm.sendTokens(0, {from: accounts[5]});
206+
assert(false, 'should have thrown');
207+
} catch(e) {
208+
assert(help.isInvalidOpcodeEx(e));
209+
}
210+
211+
assert.equal(100, parseInt(await token.totalSupply.call()));
212+
await mvm.sendTokens(50, {from: accounts[5]});
213+
214+
assert.equal(50, parseInt(await token.totalSupply.call()),
215+
'total supply has decrease to 50 because of burned tokens');
216+
});
217+
189218
it('Create 24 months MM', async function() {
190219
const mmInitialBalance = 20000000;
191220
const totalTokenSupply = 100;

0 commit comments

Comments
 (0)