-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathExceptions.js
20 lines (19 loc) · 994 Bytes
/
Exceptions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
async function tryCatch(promise, message) {
try {
await promise;
throw null;
}
catch (error) {
assert(error, "Expected an error but did not get one");
assert(error.message.includes(message));
}
}
module.exports = {
catchRevert : async function(promise) {await tryCatch(promise, "revert" );},
catchOutOfGas : async function(promise) {await tryCatch(promise, "out of gas" );},
catchInvalidJump : async function(promise) {await tryCatch(promise, "invalid JUMP" );},
catchInvalidOpcode : async function(promise) {await tryCatch(promise, "invalid opcode" );},
catchStackOverflow : async function(promise) {await tryCatch(promise, "stack overflow" );},
catchStackUnderflow : async function(promise) {await tryCatch(promise, "stack underflow" );},
catchStaticStateChange : async function(promise) {await tryCatch(promise, "static state change");},
};