liquid-funding/test/helpers/assertFail.js

18 lines
534 B
JavaScript
Raw Normal View History

2017-07-13 17:12:45 +00:00
const chai = require('chai');
const assert = chai.assert;
module.exports = async function(promise) {
2017-06-27 11:08:23 +00:00
let web3_error_thrown = false;
try {
await promise
.then(({ status }) => {
if (status === '0x00') {
web3_error_thrown = true;
}
});
2017-06-27 11:08:23 +00:00
} catch (error) {
2018-01-22 19:00:30 +00:00
if (error.message.includes("invalid opcode") || error.message.includes('revert')) web3_error_thrown = true;
2017-06-27 11:08:23 +00:00
}
assert.ok(web3_error_thrown, "Transaction should fail");
};