aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/utils/assertions.ts
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-06-06 07:45:37 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-06-07 03:41:14 +0800
commitba6806df5d2d4b31c125a0c58cc6cd65bf555933 (patch)
tree2519d43d70f8f7d6c610bb2de51a17f37f15c9aa /packages/contracts/src/utils/assertions.ts
parentfe121012784e0f1ed844c3ce6190e2d5b258b55e (diff)
downloaddexon-sol-tools-ba6806df5d2d4b31c125a0c58cc6cd65bf555933.tar
dexon-sol-tools-ba6806df5d2d4b31c125a0c58cc6cd65bf555933.tar.gz
dexon-sol-tools-ba6806df5d2d4b31c125a0c58cc6cd65bf555933.tar.bz2
dexon-sol-tools-ba6806df5d2d4b31c125a0c58cc6cd65bf555933.tar.lz
dexon-sol-tools-ba6806df5d2d4b31c125a0c58cc6cd65bf555933.tar.xz
dexon-sol-tools-ba6806df5d2d4b31c125a0c58cc6cd65bf555933.tar.zst
dexon-sol-tools-ba6806df5d2d4b31c125a0c58cc6cd65bf555933.zip
Fix linter errors
Diffstat (limited to 'packages/contracts/src/utils/assertions.ts')
-rw-r--r--packages/contracts/src/utils/assertions.ts29
1 files changed, 29 insertions, 0 deletions
diff --git a/packages/contracts/src/utils/assertions.ts b/packages/contracts/src/utils/assertions.ts
index c08bc7271..fc57f93fb 100644
--- a/packages/contracts/src/utils/assertions.ts
+++ b/packages/contracts/src/utils/assertions.ts
@@ -17,18 +17,47 @@ function _expectEitherError<T>(p: Promise<T>, error1: string, error2: string): P
});
}
+/**
+ * Rejects if the given Promise does not reject with an error indicating
+ * insufficient funds.
+ * @param p the Promise which is expected to reject
+ * @returns a new Promise which will reject if the conditions are not met and
+ * otherwise resolve with no value.
+ */
export function expectInsufficientFunds<T>(p: Promise<T>): PromiseLike<void> {
return _expectEitherError(p, 'insufficient funds', "sender doesn't have enough funds");
}
+/**
+ * Rejects if the given Promise does not reject with a "revert" error or the
+ * given otherError.
+ * @param p the Promise which is expected to reject
+ * @param otherError the other error which is accepted as a valid reject error.
+ * @returns a new Promise which will reject if the conditions are not met and
+ * otherwise resolve with no value.
+ */
export function expectRevertOrOtherError<T>(p: Promise<T>, otherError: string): PromiseLike<void> {
return _expectEitherError(p, constants.REVERT, otherError);
}
+/**
+ * Rejects if the given Promise does not reject with a "revert" or "always
+ * failing transaction" error.
+ * @param p the Promise which is expected to reject
+ * @returns a new Promise which will reject if the conditions are not met and
+ * otherwise resolve with no value.
+ */
export function expectRevertOrAlwaysFailingTransaction<T>(p: Promise<T>): PromiseLike<void> {
return expectRevertOrOtherError(p, 'always failing transaction');
}
+/**
+ * Rejects if the given Promise does not reject with a "revert" or "Contract
+ * call failed" error.
+ * @param p the Promise which is expected to reject
+ * @returns a new Promise which will reject if the conditions are not met and
+ * otherwise resolve with no value.
+ */
export function expectRevertOrContractCallFailed<T>(p: Promise<T>): PromiseLike<void> {
return expectRevertOrOtherError<T>(p, 'Contract call failed');
}