|
1 | 1 | var LifCrowdsale = artifacts.require('./LifCrowdsale.sol'),
|
2 |
| - LifToken = artifacts.require('./LifToken.sol'); |
| 2 | + LifToken = artifacts.require('./LifToken.sol'), |
| 3 | + LifMarketValidationMechanism = artifacts.require('./LifMarketValidationMechanism.sol'); |
3 | 4 |
|
4 | 5 | let help = require('./helpers');
|
5 | 6 |
|
@@ -400,4 +401,56 @@ contract('LifToken Crowdsale', function(accounts) {
|
400 | 401 | }
|
401 | 402 | });
|
402 | 403 |
|
| 404 | + /// finalize |
| 405 | + it('finalize creates the MVM', async function() { |
| 406 | + const start = latestTime() + defaultTimeDelta, |
| 407 | + end1 = start + defaultTimeDelta, |
| 408 | + end2 = end1 + defaultTimeDelta, |
| 409 | + beneficiary = accounts[6], |
| 410 | + crowdsale = await createCrowdsale({ |
| 411 | + start: start, |
| 412 | + end1: end1, |
| 413 | + end2: end2 |
| 414 | + }), |
| 415 | + weiPerUsd = 10000, |
| 416 | + weiAmount = 10000001 * weiPerUsd; // exactly USD 1 more than the minimum for the MVM |
| 417 | + |
| 418 | + await crowdsale.setWeiPerUSDinTGE(weiPerUsd); |
| 419 | + await increaseTimeTestRPCTo(start + 2); |
| 420 | + await crowdsale.buyTokens(beneficiary, {value: weiAmount, from: accounts[5]}); |
| 421 | + |
| 422 | + await increaseTimeTestRPCTo(end2 + 2); |
| 423 | + await crowdsale.finalize(); |
| 424 | + |
| 425 | + const MVMAddress = await crowdsale.MVM.call(); |
| 426 | + assert(MVMAddress !== help.zeroAddress); |
| 427 | + |
| 428 | + const MVM = LifMarketValidationMechanism.at(MVMAddress), |
| 429 | + MVMInitialWei = await MVM.initialWei(); |
| 430 | + MVMInitialWei.should.be.bignumber.equal(1 * weiPerUsd); |
| 431 | + }); |
| 432 | + |
| 433 | + it('finalize not over soft cap does not create the MVM', async function() { |
| 434 | + const start = latestTime() + defaultTimeDelta, |
| 435 | + end1 = start + defaultTimeDelta, |
| 436 | + end2 = end1 + defaultTimeDelta, |
| 437 | + beneficiary = accounts[6], |
| 438 | + crowdsale = await createCrowdsale({ |
| 439 | + start: start, |
| 440 | + end1: end1, |
| 441 | + end2: end2 |
| 442 | + }), |
| 443 | + weiPerUsd = 10000, |
| 444 | + weiAmount = 10000000 * weiPerUsd; // exactly the soft cap |
| 445 | + |
| 446 | + await crowdsale.setWeiPerUSDinTGE(weiPerUsd); |
| 447 | + await increaseTimeTestRPCTo(start + 2); |
| 448 | + await crowdsale.buyTokens(beneficiary, {value: weiAmount, from: accounts[5]}); |
| 449 | + |
| 450 | + await increaseTimeTestRPCTo(end2 + 2); |
| 451 | + await crowdsale.finalize(); |
| 452 | + |
| 453 | + const MVMAddress = await crowdsale.MVM.call(); |
| 454 | + assert(MVMAddress === help.zeroAddress, 'no MVM should have been created: ' + MVMAddress); |
| 455 | + }); |
403 | 456 | });
|
0 commit comments