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:
committed by
Nicolás Venturo
parent
4a0a67b04c
commit
3682c6575c
@ -13,9 +13,9 @@ contract('SafeMath', function () {
|
||||
(await fn(rhs, lhs)).should.be.bignumber.equal(expected);
|
||||
}
|
||||
|
||||
async function testFailsCommutative (fn, lhs, rhs) {
|
||||
await shouldFail.reverting(fn(lhs, rhs));
|
||||
await shouldFail.reverting(fn(rhs, lhs));
|
||||
async function testFailsCommutative (fn, lhs, rhs, reason) {
|
||||
await shouldFail.reverting.withMessage(fn(lhs, rhs), reason);
|
||||
await shouldFail.reverting.withMessage(fn(rhs, lhs), reason);
|
||||
}
|
||||
|
||||
describe('add', function () {
|
||||
@ -30,7 +30,7 @@ contract('SafeMath', function () {
|
||||
const a = MAX_UINT256;
|
||||
const b = new BN('1');
|
||||
|
||||
await testFailsCommutative(this.safeMath.add, a, b);
|
||||
await testFailsCommutative(this.safeMath.add, a, b, 'SafeMath: addition overflow');
|
||||
});
|
||||
});
|
||||
|
||||
@ -46,7 +46,7 @@ contract('SafeMath', function () {
|
||||
const a = new BN('1234');
|
||||
const b = new BN('5678');
|
||||
|
||||
await shouldFail.reverting(this.safeMath.sub(a, b));
|
||||
await shouldFail.reverting.withMessage(this.safeMath.sub(a, b), 'SafeMath: subtraction overflow');
|
||||
});
|
||||
});
|
||||
|
||||
@ -69,7 +69,7 @@ contract('SafeMath', function () {
|
||||
const a = MAX_UINT256;
|
||||
const b = new BN('2');
|
||||
|
||||
await testFailsCommutative(this.safeMath.mul, a, b);
|
||||
await testFailsCommutative(this.safeMath.mul, a, b, 'SafeMath: multiplication overflow');
|
||||
});
|
||||
});
|
||||
|
||||
@ -99,7 +99,7 @@ contract('SafeMath', function () {
|
||||
const a = new BN('5678');
|
||||
const b = new BN('0');
|
||||
|
||||
await shouldFail.reverting(this.safeMath.div(a, b));
|
||||
await shouldFail.reverting.withMessage(this.safeMath.div(a, b), 'SafeMath: division by zero');
|
||||
});
|
||||
});
|
||||
|
||||
@ -138,7 +138,7 @@ contract('SafeMath', function () {
|
||||
const a = new BN('5678');
|
||||
const b = new BN('0');
|
||||
|
||||
await shouldFail.reverting(this.safeMath.mod(a, b));
|
||||
await shouldFail.reverting.withMessage(this.safeMath.mod(a, b), 'SafeMath: modulo by zero');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user