From 6e055019d4ab1815f928f13b0825689c856ab14d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Venturo?= Date: Thu, 18 Oct 2018 16:36:11 -0300 Subject: [PATCH] Closing time must be strictly after opening time. (#1440) (cherry picked from commit 1c5f16ae2659c3c158baebff077cc414fd9c5991) --- contracts/crowdsale/validation/TimedCrowdsale.sol | 2 +- test/crowdsale/TimedCrowdsale.test.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/contracts/crowdsale/validation/TimedCrowdsale.sol b/contracts/crowdsale/validation/TimedCrowdsale.sol index d39242578..73d6a5c0f 100644 --- a/contracts/crowdsale/validation/TimedCrowdsale.sol +++ b/contracts/crowdsale/validation/TimedCrowdsale.sol @@ -29,7 +29,7 @@ contract TimedCrowdsale is Crowdsale { constructor(uint256 openingTime, uint256 closingTime) internal { // solium-disable-next-line security/no-block-members require(openingTime >= block.timestamp); - require(closingTime >= openingTime); + require(closingTime > openingTime); _openingTime = openingTime; _closingTime = closingTime; diff --git a/test/crowdsale/TimedCrowdsale.test.js b/test/crowdsale/TimedCrowdsale.test.js index eb2a9bf51..5b0b457b7 100644 --- a/test/crowdsale/TimedCrowdsale.test.js +++ b/test/crowdsale/TimedCrowdsale.test.js @@ -29,18 +29,24 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { this.token = await SimpleToken.new(); }); - it('rejects an opening time in the past', async function () { + it('reverts if the opening time is in the past', async function () { await shouldFail.reverting(TimedCrowdsaleImpl.new( (await time.latest()) - time.duration.days(1), this.closingTime, rate, wallet, this.token.address )); }); - it('rejects a closing time before the opening time', async function () { + it('reverts if the closing time is before the opening time', async function () { await shouldFail.reverting(TimedCrowdsaleImpl.new( this.openingTime, this.openingTime - time.duration.seconds(1), rate, wallet, this.token.address )); }); + it('reverts if the closing time equals the opening time', async function () { + await shouldFail.reverting(TimedCrowdsaleImpl.new( + this.openingTime, this.openingTime, rate, wallet, this.token.address + )); + }); + context('with crowdsale', function () { beforeEach(async function () { this.crowdsale = await TimedCrowdsaleImpl.new(