Skip to content

Commit

Permalink
IncPriceCrowdsale consistently returns 0 outside of the crowdsale win…
Browse files Browse the repository at this point in the history
…dow. (#1442)
  • Loading branch information
nventuro authored Oct 18, 2018
1 parent 1c5f16a commit 9155bfe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contracts/crowdsale/price/IncreasingPriceCrowdsale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale {
* @return The number of tokens a buyer gets per wei at a given time
*/
function getCurrentRate() public view returns (uint256) {
if (!isOpen()) {
return 0;
}

// solium-disable-next-line security/no-block-members
uint256 elapsedTime = block.timestamp.sub(openingTime());
uint256 timeRange = closingTime().sub(openingTime());
Expand Down
9 changes: 9 additions & 0 deletions test/crowdsale/IncreasingPriceCrowdsale.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser])
(await this.crowdsale.finalRate()).should.be.bignumber.equal(finalRate);
});

it('returns a rate of 0 before the crowdsale starts', async function () {
(await this.crowdsale.getCurrentRate()).should.be.bignumber.equal(0);
});

it('returns a rate of 0 after the crowdsale ends', async function () {
await time.increaseTo(this.afterClosingTime);
(await this.crowdsale.getCurrentRate()).should.be.bignumber.equal(0);
});

it('at start', async function () {
await time.increaseTo(this.startTime);
await this.crowdsale.buyTokens(investor, { value, from: purchaser });
Expand Down

0 comments on commit 9155bfe

Please sign in to comment.