Test/assertRevert: Fix late return bug (#1123)
We now ensure that if an exception is thrown while awaiting the promise, the exception _has_ to be a revert. We throw 'Expected revert not received' only afterwards. This solves any problems with confusing the word 'revert'. Fix #775
This commit is contained in:
committed by
Nicolás Venturo
parent
567b773242
commit
2f6c8b05f6
@ -1,11 +1,12 @@
|
|||||||
async function assertRevert (promise) {
|
async function assertRevert (promise) {
|
||||||
try {
|
try {
|
||||||
await promise;
|
await promise;
|
||||||
assert.fail('Expected revert not received');
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const revertFound = error.message.search('revert') >= 0;
|
const revertFound = error.message.search('revert') >= 0;
|
||||||
assert(revertFound, `Expected "revert", got ${error} instead`);
|
assert(revertFound, `Expected "revert", got ${error} instead`);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
assert.fail('Expected revert not received');
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
Reference in New Issue
Block a user