From 4fc6bb7977f9f00c61cfd03f7450fe820f6b399d Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Sat, 12 Aug 2017 21:33:32 -0300 Subject: [PATCH 1/2] remove token.finishMinting() from default finalization --- contracts/crowdsale/FinalizableCrowdsale.sol | 17 +++++++++-------- test/FinalizableCrowdsale.js | 7 ------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/contracts/crowdsale/FinalizableCrowdsale.sol b/contracts/crowdsale/FinalizableCrowdsale.sol index 1a736083c72..b9920bacac5 100644 --- a/contracts/crowdsale/FinalizableCrowdsale.sol +++ b/contracts/crowdsale/FinalizableCrowdsale.sol @@ -16,8 +16,10 @@ contract FinalizableCrowdsale is Crowdsale, Ownable { event Finalized(); - // should be called after crowdsale ends, to do - // some extra finalization work + /** + * @dev Must be called after crowdsale ends, to do some extra finalization + * work. Calls the contract's finalization function. + */ function finalize() onlyOwner { require(!isFinalized); require(hasEnded()); @@ -28,12 +30,11 @@ contract FinalizableCrowdsale is Crowdsale, Ownable { isFinalized = true; } - // end token minting on finalization - // override this with custom logic if needed + /** + * @dev Can be overriden to add finalization logic. The overriding function + * should call super.finalization() to ensure the chain of finalization is + * executed entirely. + */ function finalization() internal { - token.finishMinting(); } - - - } diff --git a/test/FinalizableCrowdsale.js b/test/FinalizableCrowdsale.js index a7e76bfbf3f..f2266df74b1 100644 --- a/test/FinalizableCrowdsale.js +++ b/test/FinalizableCrowdsale.js @@ -60,11 +60,4 @@ contract('FinalizableCrowdsale', function ([_, owner, wallet, thirdparty]) { should.exist(event) }) - it('finishes minting of token', async function () { - await increaseTimeTo(this.afterEndTime) - await this.crowdsale.finalize({from: owner}) - const finished = await this.token.mintingFinished() - finished.should.equal(true) - }) - }) From 36452136f1ef26ecfeed3fa07404e3ec113c4489 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Sun, 13 Aug 2017 22:41:25 -0300 Subject: [PATCH 2/2] add test for finishMinting --- test/MintableToken.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/MintableToken.js b/test/MintableToken.js index a3ae8968e2c..f6af9ebac61 100644 --- a/test/MintableToken.js +++ b/test/MintableToken.js @@ -1,6 +1,6 @@ 'use strict'; -const assertJump = require('./helpers/assertJump'); +import expectThrow from './helpers/expectThrow'; var MintableToken = artifacts.require('../contracts/Tokens/MintableToken.sol'); contract('Mintable', function(accounts) { @@ -37,4 +37,10 @@ contract('Mintable', function(accounts) { assert(totalSupply, 100); }) + it('should fail to mint after call to finishMinting', async function () { + await token.finishMinting(); + assert.equal(await token.mintingFinished(), true); + await expectThrow(token.mint(accounts[0], 100)); + }) + });