Added message string for require() (#1704)

* Error handling in ERC20 and ERC721

* Added message string for require.

* Fixed solhint errors.

* Updated PR as per issue #1709

* changes as per #1709 and openzeppelin forum.

* Changes in require statement

* Changes in require statement

* build pipeline fix

* Changes as per @nventuro's comment.

* Update revert reason strings.

* Fianal update of revert reason strings.

* WIP: Updating reason strings in test cases

* WIP: Added changes to ERC20 and ERC721

* Fixes linting errors in *.tes.js files

* Achieved 100% code coverage

* Updated the test cases with shouldFail.reverting.withMessage()

* Fix package-lock.

* address review comments

* fix linter issues

* fix remaining revert reasons
This commit is contained in:
Balaji Pachai
2019-04-24 19:47:08 +05:30
committed by Nicolás Venturo
parent 4a0a67b04c
commit 3682c6575c
93 changed files with 769 additions and 423 deletions

View File

@ -38,8 +38,10 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) {
});
it('should not accept payments before start', async function () {
await shouldFail.reverting(this.crowdsale.send(ether('1')));
await shouldFail.reverting(this.crowdsale.buyTokens(investor, { from: investor, value: ether('1') }));
await shouldFail.reverting.withMessage(this.crowdsale.send(ether('1')), 'TimedCrowdsale: not open');
await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(investor, { from: investor, value: ether('1') }),
'TimedCrowdsale: not open'
);
});
it('should accept payments during the sale', async function () {
@ -55,14 +57,16 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) {
it('should reject payments after end', async function () {
await time.increaseTo(this.afterClosingTime);
await shouldFail.reverting(this.crowdsale.send(ether('1')));
await shouldFail.reverting(this.crowdsale.buyTokens(investor, { value: ether('1'), from: investor }));
await shouldFail.reverting.withMessage(this.crowdsale.send(ether('1')), 'TimedCrowdsale: not open');
await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(investor, { value: ether('1'), from: investor }),
'TimedCrowdsale: not open'
);
});
it('should reject payments over cap', async function () {
await time.increaseTo(this.openingTime);
await this.crowdsale.send(CAP);
await shouldFail.reverting(this.crowdsale.send(1));
await shouldFail.reverting.withMessage(this.crowdsale.send(1), 'CappedCrowdsale: cap exceeded');
});
it('should allow finalization and transfer funds to wallet if the goal is reached', async function () {
@ -93,9 +97,9 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) {
const HIGH_GOAL = ether('30');
it('creation reverts', async function () {
await shouldFail.reverting(SampleCrowdsale.new(
await shouldFail.reverting.withMessage(SampleCrowdsale.new(
this.openingTime, this.closingTime, RATE, wallet, CAP, this.token.address, HIGH_GOAL
));
), 'SampleCrowdSale: goal is greater than cap');
});
});
});