-
-
Save reime005/e888e9f364e006bdbc2728f2d15049b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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