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
@ -9,7 +9,9 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
|
||||
const totalSupply = new BN('200');
|
||||
|
||||
it('reverts with a null legacy token address', async function () {
|
||||
await shouldFail.reverting(ERC20Migrator.new(ZERO_ADDRESS));
|
||||
await shouldFail.reverting.withMessage(ERC20Migrator.new(ZERO_ADDRESS),
|
||||
'ERC20Migrator: legacy token is the zero address'
|
||||
);
|
||||
});
|
||||
|
||||
describe('with tokens and migrator', function () {
|
||||
@ -25,11 +27,15 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
|
||||
|
||||
describe('beginMigration', function () {
|
||||
it('reverts with a null new token address', async function () {
|
||||
await shouldFail.reverting(this.migrator.beginMigration(ZERO_ADDRESS));
|
||||
await shouldFail.reverting.withMessage(this.migrator.beginMigration(ZERO_ADDRESS),
|
||||
'ERC20Migrator: new token is the zero address'
|
||||
);
|
||||
});
|
||||
|
||||
it('reverts if not a minter of the token', async function () {
|
||||
await shouldFail.reverting(this.migrator.beginMigration(this.newToken.address));
|
||||
await shouldFail.reverting.withMessage(this.migrator.beginMigration(this.newToken.address),
|
||||
'ERC20Migrator: not a minter for new token'
|
||||
);
|
||||
});
|
||||
|
||||
it('succeeds if it is a minter of the token', async function () {
|
||||
@ -40,7 +46,9 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
|
||||
it('reverts the second time it is called', async function () {
|
||||
await this.newToken.addMinter(this.migrator.address);
|
||||
await this.migrator.beginMigration(this.newToken.address);
|
||||
await shouldFail.reverting(this.migrator.beginMigration(this.newToken.address));
|
||||
await shouldFail.reverting.withMessage(this.migrator.beginMigration(this.newToken.address),
|
||||
'ERC20Migrator: migration already started'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@ -58,7 +66,9 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
|
||||
});
|
||||
|
||||
it('reverts', async function () {
|
||||
await shouldFail.reverting(this.migrator.migrateAll(owner));
|
||||
await shouldFail.reverting.withMessage(this.migrator.migrateAll(owner),
|
||||
'ERC20Migrator: migration not started'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -72,7 +82,9 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
|
||||
});
|
||||
|
||||
it('reverts', async function () {
|
||||
await shouldFail.reverting(this.migrator.migrate(owner, amount));
|
||||
await shouldFail.reverting.withMessage(this.migrator.migrate(owner, amount),
|
||||
'ERC20Migrator: migration not started'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -174,7 +186,9 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
|
||||
const amount = baseAmount.addn(1);
|
||||
|
||||
it('reverts', async function () {
|
||||
await shouldFail.reverting(this.migrator.migrate(owner, amount));
|
||||
await shouldFail.reverting.withMessage(this.migrator.migrate(owner, amount),
|
||||
'SafeERC20: low-level call failed'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user