aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts/src')
-rw-r--r--packages/contracts/src/utils/assertions.ts12
-rw-r--r--packages/contracts/src/utils/constants.ts1
2 files changed, 13 insertions, 0 deletions
diff --git a/packages/contracts/src/utils/assertions.ts b/packages/contracts/src/utils/assertions.ts
index 1e8d58b9f..4fc410363 100644
--- a/packages/contracts/src/utils/assertions.ts
+++ b/packages/contracts/src/utils/assertions.ts
@@ -30,3 +30,15 @@ export function expectInsufficientFunds<T>(p: Promise<T>): PromiseLike<void> {
);
});
}
+
+export function expectRevertOrContractCallFailed<T>(p: Promise<T>): PromiseLike<void> {
+ return expect(p)
+ .to.be.rejected()
+ .then(e => {
+ expect(e).to.satisfy(
+ (err: Error) =>
+ _.includes(err.message, constants.REVERT) ||
+ _.includes(err.message, constants.CONTRACT_CALL_FAILED),
+ );
+ });
+}
diff --git a/packages/contracts/src/utils/constants.ts b/packages/contracts/src/utils/constants.ts
index 60f41b51b..a21ca29ed 100644
--- a/packages/contracts/src/utils/constants.ts
+++ b/packages/contracts/src/utils/constants.ts
@@ -20,6 +20,7 @@ export const constants = {
INVALID_OPCODE: 'invalid opcode',
REVERT: 'revert',
ALWAYS_FAILING_TRANSACTION: 'always failing transaction',
+ CONTRACT_CALL_FAILED: 'Contract call failed',
LIB_BYTES_GT_ZERO_LENGTH_REQUIRED: 'Length must be greater than 0.',
LIB_BYTES_GTE_4_LENGTH_REQUIRED: 'Length must be greater than or equal to 4.',
LIB_BYTES_GTE_20_LENGTH_REQUIRED: 'Length must be greater than or equal to 20.',