From 950b6a5e568310380a8a4aaafd4edf9339a63658 Mon Sep 17 00:00:00 2001 From: Jakub Wojciechowski Date: Fri, 14 Jul 2017 16:14:56 +0100 Subject: [PATCH] sanity check for RefundableCrowdsale: goal > 0 --- contracts/crowdsale/RefundableCrowdsale.sol | 1 + test/RefundableCrowdsale.js | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/contracts/crowdsale/RefundableCrowdsale.sol b/contracts/crowdsale/RefundableCrowdsale.sol index f45df1d33..f5b44cda4 100644 --- a/contracts/crowdsale/RefundableCrowdsale.sol +++ b/contracts/crowdsale/RefundableCrowdsale.sol @@ -22,6 +22,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale { RefundVault public vault; function RefundableCrowdsale(uint256 _goal) { + require(_goal > 0); vault = new RefundVault(wallet); goal = _goal; } diff --git a/test/RefundableCrowdsale.js b/test/RefundableCrowdsale.js index 76f2e22c3..f1d6fda68 100644 --- a/test/RefundableCrowdsale.js +++ b/test/RefundableCrowdsale.js @@ -17,6 +17,15 @@ contract('RefundableCrowdsale', function ([_, owner, wallet, investor]) { const goal = ether(800) const lessThanGoal = ether(750) + describe('creating a valid crowdsale', function () { + + it('should fail with zero goal', async function () { + await RefundableCrowdsale.new(this.startBlock, this.endBlock, rate, wallet, 0, {from: owner}).should.be.rejectedWith(EVMThrow); + }) + + }); + + beforeEach(async function () { this.startBlock = web3.eth.blockNumber + 10 this.endBlock = web3.eth.blockNumber + 20