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:
Nicolás Venturo
2018-11-27 17:20:21 -03:00
committed by GitHub
parent 21ed6bee25
commit f0e12d5301
4 changed files with 146 additions and 7 deletions

View File

@ -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;