diff options
author | Fabio Berger <me@fabioberger.com> | 2018-06-25 18:32:16 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-06-25 18:32:16 +0800 |
commit | c50da5d0344cd23392f71d213fff9dfec7ec71c9 (patch) | |
tree | 067e106202a83c0cd3bc929a940145100293f2b1 /packages/contracts/test/exchange/wrapper.ts | |
parent | 9b196ba68c9f958cd82ef99ae87fdd87c70441a9 (diff) | |
parent | df79fb19aff1aa1ed7b1346feccfa3d235c25ea0 (diff) | |
download | dexon-sol-tools-c50da5d0344cd23392f71d213fff9dfec7ec71c9.tar dexon-sol-tools-c50da5d0344cd23392f71d213fff9dfec7ec71c9.tar.gz dexon-sol-tools-c50da5d0344cd23392f71d213fff9dfec7ec71c9.tar.bz2 dexon-sol-tools-c50da5d0344cd23392f71d213fff9dfec7ec71c9.tar.lz dexon-sol-tools-c50da5d0344cd23392f71d213fff9dfec7ec71c9.tar.xz dexon-sol-tools-c50da5d0344cd23392f71d213fff9dfec7ec71c9.tar.zst dexon-sol-tools-c50da5d0344cd23392f71d213fff9dfec7ec71c9.zip |
merge check-revert-reasons
Diffstat (limited to 'packages/contracts/test/exchange/wrapper.ts')
-rw-r--r-- | packages/contracts/test/exchange/wrapper.ts | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts index af39855de..c652d22e5 100644 --- a/packages/contracts/test/exchange/wrapper.ts +++ b/packages/contracts/test/exchange/wrapper.ts @@ -12,14 +12,14 @@ import { ERC20ProxyContract } from '../../src/generated_contract_wrappers/e_r_c2 import { ERC721ProxyContract } from '../../src/generated_contract_wrappers/e_r_c721_proxy'; import { ExchangeContract } from '../../src/generated_contract_wrappers/exchange'; import { artifacts } from '../../src/utils/artifacts'; -import { expectRevertOrAlwaysFailingTransactionAsync } from '../../src/utils/assertions'; +import { expectRevertReasonOrAlwaysFailingTransactionAsync } from '../../src/utils/assertions'; import { chaiSetup } from '../../src/utils/chai_setup'; import { constants } from '../../src/utils/constants'; import { ERC20Wrapper } from '../../src/utils/erc20_wrapper'; import { ERC721Wrapper } from '../../src/utils/erc721_wrapper'; import { ExchangeWrapper } from '../../src/utils/exchange_wrapper'; import { OrderFactory } from '../../src/utils/order_factory'; -import { ERC20BalancesByOwner } from '../../src/utils/types'; +import { ERC20BalancesByOwner, RevertReasons } from '../../src/utils/types'; import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper'; chaiSetup.configure(); @@ -168,13 +168,14 @@ describe('Exchange wrappers', () => { ); }); - it('should throw if an signedOrder is expired', async () => { + it('should throw if a signedOrder is expired', async () => { const signedOrder = orderFactory.newSignedOrder({ expirationTimeSeconds: new BigNumber(Math.floor((Date.now() - 10000) / 1000)), }); - return expectRevertOrAlwaysFailingTransactionAsync( + return expectRevertReasonOrAlwaysFailingTransactionAsync( exchangeWrapper.fillOrKillOrderAsync(signedOrder, takerAddress), + RevertReasons.OrderUnfillable, ); }); @@ -185,8 +186,9 @@ describe('Exchange wrappers', () => { takerAssetFillAmount: signedOrder.takerAssetAmount.div(2), }); - return expectRevertOrAlwaysFailingTransactionAsync( + return expectRevertReasonOrAlwaysFailingTransactionAsync( exchangeWrapper.fillOrKillOrderAsync(signedOrder, takerAddress), + RevertReasons.CompleteFillFailed, ); }); }); @@ -497,10 +499,11 @@ describe('Exchange wrappers', () => { await exchangeWrapper.fillOrKillOrderAsync(signedOrders[0], takerAddress); - return expectRevertOrAlwaysFailingTransactionAsync( + return expectRevertReasonOrAlwaysFailingTransactionAsync( exchangeWrapper.batchFillOrKillOrdersAsync(signedOrders, takerAddress, { takerAssetFillAmounts, }), + RevertReasons.OrderUnfillable, ); }); }); @@ -690,7 +693,7 @@ describe('Exchange wrappers', () => { expect(newBalances).to.be.deep.equal(erc20Balances); }); - it('should throw when an signedOrder does not use the same takerAssetAddress', async () => { + it('should throw when a signedOrder does not use the same takerAssetAddress', async () => { signedOrders = [ orderFactory.newSignedOrder(), orderFactory.newSignedOrder({ @@ -699,10 +702,13 @@ describe('Exchange wrappers', () => { orderFactory.newSignedOrder(), ]; - return expectRevertOrAlwaysFailingTransactionAsync( + return expectRevertReasonOrAlwaysFailingTransactionAsync( exchangeWrapper.marketSellOrdersAsync(signedOrders, takerAddress, { takerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18), }), + // We simply use the takerAssetData from the first order for all orders. + // If they are not the same, the contract throws when validating the order signature + RevertReasons.InvalidOrderSignature, ); }); }); @@ -905,7 +911,7 @@ describe('Exchange wrappers', () => { expect(newBalances).to.be.deep.equal(erc20Balances); }); - it('should throw when an signedOrder does not use the same makerAssetAddress', async () => { + it('should throw when a signedOrder does not use the same makerAssetAddress', async () => { signedOrders = [ orderFactory.newSignedOrder(), orderFactory.newSignedOrder({ @@ -914,10 +920,11 @@ describe('Exchange wrappers', () => { orderFactory.newSignedOrder(), ]; - return expectRevertOrAlwaysFailingTransactionAsync( + return expectRevertReasonOrAlwaysFailingTransactionAsync( exchangeWrapper.marketBuyOrdersAsync(signedOrders, takerAddress, { makerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18), }), + RevertReasons.InvalidOrderSignature, ); }); }); |