Skip to content

Commit 05e47a4

Browse files
committed
InitialRate must be strictly larger than finalRate.
1 parent 67dac7a commit 05e47a4

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

contracts/crowdsale/price/IncreasingPriceCrowdsale.sol

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

30+
function rate() public view returns(uint256) {
31+
revert();
32+
}
33+
3034
/**
3135
* @return the initial rate of the crowdsale.
3236
*/

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('at start', async function () {
6373
await time.increaseTo(this.startTime);
6474
await this.crowdsale.buyTokens(investor, { value, from: purchaser });

0 commit comments

Comments
 (0)