Files
openzeppelin-contracts/test/helpers/assertRevert.js
Justus Perlwitz 2f6c8b05f6 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
2018-07-26 23:53:06 -03:00

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,
};