* Add IntelliJ IDE config to .gitignore * Fix variable name in ERC20 function comments * Fix typos in Arrays function comment * Fix typos in ownership test names * Fix typo in Pausable test name * Fix grammar in Ownable function comment * Fix grammar in Crowdsale contract comment * Fix typo in Counters contract comment * Fix typo in ERC721Enumerable comment * Fix typo in ERC721PausedToken test name * Fix typo in Crowdsale function comment * Fix typo in IncreasingPriceCrowdsale function comment * Fix grammar in IncreasingPriceCrowdsale test name * Fix typo in AllowanceCrowdsale test name * Fix typo in RefundEscrow function comment * Fix typo in ERC20Migrator contract comment * Fix typos in SignatureBouncer comments * Fix typo in SignedSafeMath test name * Fix typo in TokenVesting contract comment * Move Ownable comment from @notice section to @dev The Ownable contract has a comment explaining that renouncing ownership will prevent execution of functions with the onlyOwner modifier. This commit moves that comment to the @dev section and replaces it with a description suitable for a generic user. * Clarify purpose of ERC20 transfer function * Clarify registration of ERC721Enumerable interface * Clarify purpose of AllowanceCrowdsale test * Increase specificity of inheritance comments FinalizableCrowdsale and RefundableCrowsale both have comments indicating that they are extensions of the Crowdsale contract. This commit refines those comments to the most immediate ancestor ( TimedCrowdsale and RefundableCrowdsale respectively ) * Remove unused parameter in PaymentSplitter test * Rename parameter in SignatureBouncer functions The SignatureBouncer contract has modifiers to validate the message sender is authorised to perform an action. They pass msg.sender to internal functions as the variable `account`, but the function comments refer to the variable as `sender` This commit changes the variable name to `sender` * Clarify comments in SignatureBouncer functions The SignatureBouncer has comments that use the description `sender` to refer to the variable `account`. This commit updates the comments for consistency. Maintainer Note: this reverts changes in the previous commit, which renamed the variable `account` instead.
116 lines
5.0 KiB
JavaScript
116 lines
5.0 KiB
JavaScript
const { BN, ether, shouldFail, time } = require('openzeppelin-test-helpers');
|
|
|
|
const IncreasingPriceCrowdsaleImpl = artifacts.require('IncreasingPriceCrowdsaleImpl');
|
|
const SimpleToken = artifacts.require('SimpleToken');
|
|
|
|
contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser]) {
|
|
const value = ether('1');
|
|
const tokenSupply = new BN('10').pow(new BN('22'));
|
|
|
|
describe('rate during crowdsale should change at a fixed step every block', async function () {
|
|
const initialRate = new BN('9166');
|
|
const finalRate = new BN('5500');
|
|
const rateAtTime150 = new BN('9166');
|
|
const rateAtTime300 = new BN('9165');
|
|
const rateAtTime1500 = new BN('9157');
|
|
const rateAtTime30 = new BN('9166');
|
|
const rateAtTime150000 = new BN('8257');
|
|
const rateAtTime450000 = new BN('6439');
|
|
|
|
beforeEach(async function () {
|
|
await time.advanceBlock();
|
|
this.startTime = (await time.latest()).add(time.duration.weeks(1));
|
|
this.closingTime = this.startTime.add(time.duration.weeks(1));
|
|
this.afterClosingTime = this.closingTime.add(time.duration.seconds(1));
|
|
this.token = await SimpleToken.new();
|
|
});
|
|
|
|
it('reverts with a final rate larger than the initial rate', async function () {
|
|
await shouldFail.reverting(IncreasingPriceCrowdsaleImpl.new(
|
|
this.startTime, this.closingTime, wallet, this.token.address, initialRate, initialRate.addn(1)
|
|
));
|
|
});
|
|
|
|
it('reverts with a final rate equal to the initial rate', async function () {
|
|
await shouldFail.reverting(IncreasingPriceCrowdsaleImpl.new(
|
|
this.startTime, this.closingTime, wallet, this.token.address, initialRate, initialRate
|
|
));
|
|
});
|
|
|
|
it('reverts with a final rate of zero', async function () {
|
|
await shouldFail.reverting(IncreasingPriceCrowdsaleImpl.new(
|
|
this.startTime, this.closingTime, wallet, this.token.address, initialRate, 0
|
|
));
|
|
});
|
|
|
|
context('with crowdsale', function () {
|
|
beforeEach(async function () {
|
|
this.crowdsale = await IncreasingPriceCrowdsaleImpl.new(
|
|
this.startTime, this.closingTime, wallet, this.token.address, initialRate, finalRate
|
|
);
|
|
await this.token.transfer(this.crowdsale.address, tokenSupply);
|
|
});
|
|
|
|
it('should have initial and final rate', async function () {
|
|
(await this.crowdsale.initialRate()).should.be.bignumber.equal(initialRate);
|
|
(await this.crowdsale.finalRate()).should.be.bignumber.equal(finalRate);
|
|
});
|
|
|
|
it('reverts when the base Crowdsale\'s rate function is called', async function () {
|
|
await shouldFail.reverting(this.crowdsale.rate());
|
|
});
|
|
|
|
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 });
|
|
(await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(initialRate));
|
|
});
|
|
|
|
it('at time 150', async function () {
|
|
await time.increaseTo(this.startTime.addn(150));
|
|
await this.crowdsale.buyTokens(investor, { value, from: purchaser });
|
|
(await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime150));
|
|
});
|
|
|
|
it('at time 300', async function () {
|
|
await time.increaseTo(this.startTime.addn(300));
|
|
await this.crowdsale.buyTokens(investor, { value, from: purchaser });
|
|
(await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime300));
|
|
});
|
|
|
|
it('at time 1500', async function () {
|
|
await time.increaseTo(this.startTime.addn(1500));
|
|
await this.crowdsale.buyTokens(investor, { value, from: purchaser });
|
|
(await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime1500));
|
|
});
|
|
|
|
it('at time 30', async function () {
|
|
await time.increaseTo(this.startTime.addn(30));
|
|
await this.crowdsale.buyTokens(investor, { value, from: purchaser });
|
|
(await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime30));
|
|
});
|
|
|
|
it('at time 150000', async function () {
|
|
await time.increaseTo(this.startTime.addn(150000));
|
|
await this.crowdsale.buyTokens(investor, { value, from: purchaser });
|
|
(await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime150000));
|
|
});
|
|
|
|
it('at time 450000', async function () {
|
|
await time.increaseTo(this.startTime.addn(450000));
|
|
await this.crowdsale.buyTokens(investor, { value, from: purchaser });
|
|
(await this.token.balanceOf(investor)).should.be.bignumber.equal(value.mul(rateAtTime450000));
|
|
});
|
|
});
|
|
});
|
|
});
|