ether and shouldFail tests (#1513)
* Added ether tests. * Added shouldFail base function and tests. * Updated test descriptions. * Reduced gas limit on out-of-gas tests.
This commit is contained in:
@ -5,11 +5,13 @@ async function shouldFailWithMessage (promise, message) {
|
||||
try {
|
||||
await promise;
|
||||
} catch (error) {
|
||||
error.message.should.include(message, 'Wrong failure type');
|
||||
if (message) {
|
||||
error.message.should.include(message, `Wrong failure type, expected '${message}'`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
should.fail(`Expected '${message}' failure not received`);
|
||||
should.fail('Expected failure not received');
|
||||
}
|
||||
|
||||
async function reverting (promise) {
|
||||
@ -24,8 +26,12 @@ async function outOfGas (promise) {
|
||||
await shouldFailWithMessage(promise, 'out of gas');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
reverting,
|
||||
throwing,
|
||||
outOfGas,
|
||||
};
|
||||
async function shouldFail (promise) {
|
||||
await shouldFailWithMessage(promise);
|
||||
}
|
||||
|
||||
shouldFail.reverting = reverting;
|
||||
shouldFail.throwing = throwing;
|
||||
shouldFail.outOfGas = outOfGas;
|
||||
|
||||
module.exports = shouldFail;
|
||||
|
||||
Reference in New Issue
Block a user