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

@ -18,7 +18,9 @@ contract('Secondary', function ([_, primary, newPrimary, other]) {
});
it('reverts when anyone calls onlyPrimary functions', async function () {
await shouldFail.reverting(this.secondary.onlyPrimaryMock({ from: other }));
await shouldFail.reverting.withMessage(this.secondary.onlyPrimaryMock({ from: other }),
'Secondary: caller is not the primary account'
);
});
});
@ -30,11 +32,15 @@ contract('Secondary', function ([_, primary, newPrimary, other]) {
});
it('reverts when transferring to the null address', async function () {
await shouldFail.reverting(this.secondary.transferPrimary(ZERO_ADDRESS, { from: primary }));
await shouldFail.reverting.withMessage(this.secondary.transferPrimary(ZERO_ADDRESS, { from: primary }),
'Secondary: new primary is the zero address'
);
});
it('reverts when called by anyone', async function () {
await shouldFail.reverting(this.secondary.transferPrimary(newPrimary, { from: other }));
await shouldFail.reverting.withMessage(this.secondary.transferPrimary(newPrimary, { from: other }),
'Secondary: caller is not the primary account'
);
});
context('with new primary', function () {
@ -47,7 +53,9 @@ contract('Secondary', function ([_, primary, newPrimary, other]) {
});
it('reverts when the old primary account calls onlyPrimary functions', async function () {
await shouldFail.reverting(this.secondary.onlyPrimaryMock({ from: primary }));
await shouldFail.reverting.withMessage(this.secondary.onlyPrimaryMock({ from: primary }),
'Secondary: caller is not the primary account'
);
});
});
});