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

@ -30,7 +30,9 @@ contract('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts]
});
it('cannot take drastic measure in non-pause', async function () {
await shouldFail.reverting(this.pausable.drasticMeasure({ from: other }));
await shouldFail.reverting.withMessage(this.pausable.drasticMeasure({ from: other }),
'Pausable: not paused'
);
(await this.pausable.drasticMeasureTaken()).should.equal(false);
});
@ -41,7 +43,9 @@ contract('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts]
});
it('reverts when pausing from non-pauser', async function () {
await shouldFail.reverting(this.pausable.pause({ from: other }));
await shouldFail.reverting.withMessage(this.pausable.pause({ from: other }),
'PauserRole: caller does not have the Pauser role'
);
});
context('when paused', function () {
@ -54,7 +58,7 @@ contract('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts]
});
it('cannot perform normal process in pause', async function () {
await shouldFail.reverting(this.pausable.normalProcess({ from: other }));
await shouldFail.reverting.withMessage(this.pausable.normalProcess({ from: other }), 'Pausable: paused');
});
it('can take a drastic measure in a pause', async function () {
@ -63,7 +67,7 @@ contract('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts]
});
it('reverts when re-pausing', async function () {
await shouldFail.reverting(this.pausable.pause({ from: pauser }));
await shouldFail.reverting.withMessage(this.pausable.pause({ from: pauser }), 'Pausable: paused');
});
describe('unpausing', function () {
@ -73,7 +77,9 @@ contract('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts]
});
it('reverts when unpausing from non-pauser', async function () {
await shouldFail.reverting(this.pausable.unpause({ from: other }));
await shouldFail.reverting.withMessage(this.pausable.unpause({ from: other }),
'PauserRole: caller does not have the Pauser role'
);
});
context('when unpaused', function () {
@ -92,11 +98,13 @@ contract('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts]
});
it('should prevent drastic measure', async function () {
await shouldFail.reverting(this.pausable.drasticMeasure({ from: other }));
await shouldFail.reverting.withMessage(this.pausable.drasticMeasure({ from: other }),
'Pausable: not paused'
);
});
it('reverts when re-unpausing', async function () {
await shouldFail.reverting(this.pausable.unpause({ from: pauser }));
await shouldFail.reverting.withMessage(this.pausable.unpause({ from: pauser }), 'Pausable: not paused');
});
});
});