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
15 lines
320 B
JavaScript
15 lines
320 B
JavaScript
async function assertRevert (promise) {
|
|
try {
|
|
await promise;
|
|
} catch (error) {
|
|
const revertFound = error.message.search('revert') >= 0;
|
|
assert(revertFound, `Expected "revert", got ${error} instead`);
|
|
return;
|
|
}
|
|
assert.fail('Expected revert not received');
|
|
}
|
|
|
|
module.exports = {
|
|
assertRevert,
|
|
};
|