2017-07-13 17:12:45 +00:00
|
|
|
const chai = require('chai');
|
|
|
|
const assert = chai.assert;
|
|
|
|
|
2018-01-25 23:09:58 +00:00
|
|
|
module.exports = async function(promise) {
|
2017-06-27 11:08:23 +00:00
|
|
|
let web3_error_thrown = false;
|
|
|
|
try {
|
2018-01-25 23:09:58 +00:00
|
|
|
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");
|
|
|
|
};
|