Skip to content

Instantly share code, notes, and snippets.

@reime005
Created December 27, 2020 22:34
Show Gist options
  • Save reime005/e888e9f364e006bdbc2728f2d15049b7 to your computer and use it in GitHub Desktop.
Save reime005/e888e9f364e006bdbc2728f2d15049b7 to your computer and use it in GitHub Desktop.
export default async function expectRevert(promise) {
try {
await promise;
} catch (error) {
const invalidJump = error.message.search("invalid JUMP") >= 0;
const revert = error.message.search("revert") >= 0;
const outOfGas = error.message.search("out of gas") >= 0;
const invalidOpcode = error.message.search("invalid opcode") >= 0;
if (revert || invalidJump || outOfGas || invalidOpcode) {
return;
}
}
assert.fail("Expected revert not received");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment