Functions in SafeMath contract overloaded to accept custom error messages (#1828)

* Imporvement: functions in SafeMath contract overloaded to accept custom error messages.

* CHANGELOG updated, custom error messages added to ERC20, ERC721 and ERC777 for subtraction related exceptions.

* SafeMath overloads for 'add' and 'mul' removed.

* Error messages modified.

* Update CHANGELOG.md
This commit is contained in:
Aram Elchyan
2019-07-29 22:23:34 +04:00
committed by Nicolás Venturo
parent 377431bc4c
commit 5d34dbecea
9 changed files with 71 additions and 27 deletions

View File

@ -88,7 +88,7 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip
it('reverts', async function () {
await expectRevert(this.token.transferFrom(
tokenOwner, to, amount, { from: spender }), 'SafeMath: subtraction overflow'
tokenOwner, to, amount, { from: spender }), `${errorPrefix}: transfer amount exceeds balance`
);
});
});
@ -104,7 +104,7 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip
it('reverts', async function () {
await expectRevert(this.token.transferFrom(
tokenOwner, to, amount, { from: spender }), 'SafeMath: subtraction overflow'
tokenOwner, to, amount, { from: spender }), `${errorPrefix}: transfer amount exceeds allowance`
);
});
});
@ -114,7 +114,7 @@ function shouldBehaveLikeERC20 (errorPrefix, initialSupply, initialHolder, recip
it('reverts', async function () {
await expectRevert(this.token.transferFrom(
tokenOwner, to, amount, { from: spender }), 'SafeMath: subtraction overflow'
tokenOwner, to, amount, { from: spender }), `${errorPrefix}: transfer amount exceeds balance`
);
});
});
@ -166,7 +166,7 @@ function shouldBehaveLikeERC20Transfer (errorPrefix, from, to, balance, transfer
it('reverts', async function () {
await expectRevert(transfer.call(this, from, to, amount),
'SafeMath: subtraction overflow'
`${errorPrefix}: transfer amount exceeds balance`
);
});
});