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

@ -7,27 +7,37 @@ contract('PaymentSplitter', function ([_, owner, payee1, payee2, payee3, nonpaye
const amount = ether('1');
it('rejects an empty set of payees', async function () {
await shouldFail.reverting(PaymentSplitter.new([], []));
await shouldFail.reverting.withMessage(PaymentSplitter.new([], []), 'PaymentSplitter: no payees');
});
it('rejects more payees than shares', async function () {
await shouldFail.reverting(PaymentSplitter.new([payee1, payee2, payee3], [20, 30]));
await shouldFail.reverting.withMessage(PaymentSplitter.new([payee1, payee2, payee3], [20, 30]),
'PaymentSplitter: payees and shares length mismatch'
);
});
it('rejects more shares than payees', async function () {
await shouldFail.reverting(PaymentSplitter.new([payee1, payee2], [20, 30, 40]));
await shouldFail.reverting.withMessage(PaymentSplitter.new([payee1, payee2], [20, 30, 40]),
'PaymentSplitter: payees and shares length mismatch'
);
});
it('rejects null payees', async function () {
await shouldFail.reverting(PaymentSplitter.new([payee1, ZERO_ADDRESS], [20, 30]));
await shouldFail.reverting.withMessage(PaymentSplitter.new([payee1, ZERO_ADDRESS], [20, 30]),
'PaymentSplitter: account is the zero address'
);
});
it('rejects zero-valued shares', async function () {
await shouldFail.reverting(PaymentSplitter.new([payee1, payee2], [20, 0]));
await shouldFail.reverting.withMessage(PaymentSplitter.new([payee1, payee2], [20, 0]),
'PaymentSplitter: shares are 0'
);
});
it('rejects repeated payees', async function () {
await shouldFail.reverting(PaymentSplitter.new([payee1, payee1], [20, 30]));
await shouldFail.reverting.withMessage(PaymentSplitter.new([payee1, payee1], [20, 30]),
'PaymentSplitter: account already has shares'
);
});
context('once deployed', function () {
@ -64,12 +74,16 @@ contract('PaymentSplitter', function ([_, owner, payee1, payee2, payee3, nonpaye
});
it('should throw if no funds to claim', async function () {
await shouldFail.reverting(this.contract.release(payee1));
await shouldFail.reverting.withMessage(this.contract.release(payee1),
'PaymentSplitter: account is not due payment'
);
});
it('should throw if non-payee want to claim', async function () {
await send.ether(payer1, this.contract.address, amount);
await shouldFail.reverting(this.contract.release(nonpayee1));
await shouldFail.reverting.withMessage(this.contract.release(nonpayee1),
'PaymentSplitter: account has no shares'
);
});
it('should distribute funds to payees', async function () {