Skip to content

Commit ecae760

Browse files
nventurocome-maiz
authored andcommitted
InitialRate must be strictly larger than finalRate. (#1441)
(cherry picked from commit a936cbf)
1 parent 47b5d61 commit ecae760

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

contracts/crowdsale/price/IncreasingPriceCrowdsale.sol

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,19 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
2222
*/
2323
constructor(uint256 initialRate, uint256 finalRate) internal {
2424
require(finalRate > 0);
25-
require(initialRate >= finalRate);
25+
require(initialRate > finalRate);
2626
_initialRate = initialRate;
2727
_finalRate = finalRate;
2828
}
2929

30+
/**
31+
* The base rate function is overridden to revert, since this crowdsale doens't use it, and
32+
* all calls to it are a mistake.
33+
*/
34+
function rate() public view returns(uint256) {
35+
revert();
36+
}
37+
3038
/**
3139
* @return the initial rate of the crowdsale.
3240
*/

test/crowdsale/IncreasingPriceCrowdsale.test.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,19 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser])
3434
this.token = await SimpleToken.new();
3535
});
3636

37-
it('rejects a final rate larger than the initial rate', async function () {
37+
it('reverts with a final rate larger than the initial rate', async function () {
3838
await shouldFail.reverting(IncreasingPriceCrowdsaleImpl.new(
3939
this.startTime, this.closingTime, wallet, this.token.address, initialRate, initialRate.plus(1)
4040
));
4141
});
4242

43-
it('rejects a final rate of zero', async function () {
43+
it('reverts with a final equal to the initial rate', async function () {
44+
await shouldFail.reverting(IncreasingPriceCrowdsaleImpl.new(
45+
this.startTime, this.closingTime, wallet, this.token.address, initialRate, initialRate
46+
));
47+
});
48+
49+
it('reverts with a final rate of zero', async function () {
4450
await shouldFail.reverting(IncreasingPriceCrowdsaleImpl.new(
4551
this.startTime, this.closingTime, wallet, this.token.address, initialRate, 0
4652
));
@@ -59,6 +65,10 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser])
5965
(await this.crowdsale.finalRate()).should.be.bignumber.equal(finalRate);
6066
});
6167

68+
it('reverts when the base Crowdsale\'s rate function is called', async function () {
69+
await shouldFail.reverting(this.crowdsale.rate());
70+
});
71+
6272
it('returns a rate of 0 before the crowdsale starts', async function () {
6373
(await this.crowdsale.getCurrentRate()).should.be.bignumber.equal(0);
6474
});

0 commit comments

Comments
 (0)