diff options
author | Fabio Berger <me@fabioberger.com> | 2018-06-25 19:51:00 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-06-25 19:51:00 +0800 |
commit | ad67a6add54cc31f4b888dbbfe70fed75b743745 (patch) | |
tree | cfa4e8a74397c77b6ab5bf7a4e88fb53fa2a8000 /packages/contracts | |
parent | 1353723b58715faf3dd10b173323dab015e2dd5b (diff) | |
download | dexon-sol-tools-ad67a6add54cc31f4b888dbbfe70fed75b743745.tar dexon-sol-tools-ad67a6add54cc31f4b888dbbfe70fed75b743745.tar.gz dexon-sol-tools-ad67a6add54cc31f4b888dbbfe70fed75b743745.tar.bz2 dexon-sol-tools-ad67a6add54cc31f4b888dbbfe70fed75b743745.tar.lz dexon-sol-tools-ad67a6add54cc31f4b888dbbfe70fed75b743745.tar.xz dexon-sol-tools-ad67a6add54cc31f4b888dbbfe70fed75b743745.tar.zst dexon-sol-tools-ad67a6add54cc31f4b888dbbfe70fed75b743745.zip |
Check revert reasons in declarative and combinatorial tests
Diffstat (limited to 'packages/contracts')
-rw-r--r-- | packages/contracts/src/utils/core_combinatorial_utils.ts | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/packages/contracts/src/utils/core_combinatorial_utils.ts b/packages/contracts/src/utils/core_combinatorial_utils.ts index 7e9d18e46..aea9a65e7 100644 --- a/packages/contracts/src/utils/core_combinatorial_utils.ts +++ b/packages/contracts/src/utils/core_combinatorial_utils.ts @@ -16,7 +16,7 @@ import 'make-promises-safe'; import { ExchangeContract, FillContractEventArgs } from '../generated_contract_wrappers/exchange'; import { artifacts } from '../utils/artifacts'; -import { expectRevertOrAlwaysFailingTransactionAsync } from '../utils/assertions'; +import { expectRevertReasonOrAlwaysFailingTransactionAsync } from '../utils/assertions'; import { AssetWrapper } from '../utils/asset_wrapper'; import { chaiSetup } from '../utils/chai_setup'; import { constants } from '../utils/constants'; @@ -298,7 +298,7 @@ export class CoreCombinatorialUtils { const lazyStore = new BalanceAndProxyAllowanceLazyStore(balanceAndProxyAllowanceFetcher); const exchangeTransferSimulator = new ExchangeTransferSimulator(lazyStore); - let isFillFailureExpected = false; + let fillRevertReasonIfExists; try { await orderValidationUtils.validateFillOrderThrowIfInvalidAsync( exchangeTransferSimulator, @@ -312,7 +312,7 @@ export class CoreCombinatorialUtils { logUtils.log(`Expecting fillOrder to succeed.`); } } catch (err) { - isFillFailureExpected = true; + fillRevertReasonIfExists = err.message; if (isVerbose) { logUtils.log(`Expecting fillOrder to fail with:`); logUtils.log(err); @@ -324,7 +324,7 @@ export class CoreCombinatorialUtils { signedOrder, takerAssetFillAmount, lazyStore, - isFillFailureExpected, + fillRevertReasonIfExists, provider, ); } @@ -332,12 +332,13 @@ export class CoreCombinatorialUtils { signedOrder: SignedOrder, takerAssetFillAmount: BigNumber, lazyStore: BalanceAndProxyAllowanceLazyStore, - isFillFailureExpected: boolean, + fillRevertReasonIfExists: string | undefined, provider: Provider, ): Promise<void> { - if (isFillFailureExpected) { - return expectRevertOrAlwaysFailingTransactionAsync( + if (!_.isUndefined(fillRevertReasonIfExists)) { + return expectRevertReasonOrAlwaysFailingTransactionAsync( this.exchangeWrapper.fillOrderAsync(signedOrder, this.takerAddress, { takerAssetFillAmount }), + fillRevertReasonIfExists, ); } |