diff options
author | Fabio Berger <me@fabioberger.com> | 2018-06-22 20:28:01 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-06-22 20:28:01 +0800 |
commit | daa50442c90f30ce7a873bf228875241a083bba5 (patch) | |
tree | d2b3f0f1216be41bb272a605939264d525e88f59 /packages/contracts | |
parent | 76fd7f47ebfb48d04faece04af0db3ab5277d864 (diff) | |
download | dexon-0x-contracts-daa50442c90f30ce7a873bf228875241a083bba5.tar dexon-0x-contracts-daa50442c90f30ce7a873bf228875241a083bba5.tar.gz dexon-0x-contracts-daa50442c90f30ce7a873bf228875241a083bba5.tar.bz2 dexon-0x-contracts-daa50442c90f30ce7a873bf228875241a083bba5.tar.lz dexon-0x-contracts-daa50442c90f30ce7a873bf228875241a083bba5.tar.xz dexon-0x-contracts-daa50442c90f30ce7a873bf228875241a083bba5.tar.zst dexon-0x-contracts-daa50442c90f30ce7a873bf228875241a083bba5.zip |
Add revert reason checks to match_orders tests
Diffstat (limited to 'packages/contracts')
-rw-r--r-- | packages/contracts/test/exchange/match_orders.ts | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/packages/contracts/test/exchange/match_orders.ts b/packages/contracts/test/exchange/match_orders.ts index b8dca04fd..6cc0631fe 100644 --- a/packages/contracts/test/exchange/match_orders.ts +++ b/packages/contracts/test/exchange/match_orders.ts @@ -12,7 +12,9 @@ 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'; @@ -20,7 +22,7 @@ import { ERC721Wrapper } from '../../src/utils/erc721_wrapper'; import { ExchangeWrapper } from '../../src/utils/exchange_wrapper'; import { MatchOrderTester } from '../../src/utils/match_order_tester'; import { OrderFactory } from '../../src/utils/order_factory'; -import { ERC20BalancesByOwner, ERC721TokenIdsByOwner, OrderInfo, OrderStatus } from '../../src/utils/types'; +import { ContractLibErrors, ERC20BalancesByOwner, ERC721TokenIdsByOwner, OrderInfo, OrderStatus } from '../../src/utils/types'; import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper'; chaiSetup.configure(); @@ -598,8 +600,9 @@ describe('matchOrders', () => { // Cancel left order await exchangeWrapper.cancelOrderAsync(signedOrderLeft, signedOrderLeft.makerAddress); // Match orders - return expectRevertOrAlwaysFailingTransactionAsync( + return expectRevertReasonOrAlwaysFailingTransactionAsync( exchangeWrapper.matchOrdersAsync(signedOrderLeft, signedOrderRight, takerAddress), + ContractLibErrors.OrderUnfillable, ); }); @@ -622,8 +625,9 @@ describe('matchOrders', () => { // Cancel right order await exchangeWrapper.cancelOrderAsync(signedOrderRight, signedOrderRight.makerAddress); // Match orders - return expectRevertOrAlwaysFailingTransactionAsync( + return expectRevertReasonOrAlwaysFailingTransactionAsync( exchangeWrapper.matchOrdersAsync(signedOrderLeft, signedOrderRight, takerAddress), + ContractLibErrors.OrderUnfillable, ); }); @@ -644,7 +648,7 @@ describe('matchOrders', () => { feeRecipientAddress: feeRecipientAddressRight, }); // Match orders - return expectRevertOrAlwaysFailingTransactionAsync( + return expectRevertReasonOrAlwaysFailingTransactionAsync( matchOrderTester.matchOrdersAndVerifyBalancesAsync( signedOrderLeft, signedOrderRight, @@ -652,6 +656,7 @@ describe('matchOrders', () => { erc20BalancesByOwner, erc721TokenIdsByOwner, ), + ContractLibErrors.NegativeSpreadRequired, ); }); @@ -672,7 +677,7 @@ describe('matchOrders', () => { feeRecipientAddress: feeRecipientAddressRight, }); // Match orders - return expectRevertOrAlwaysFailingTransactionAsync( + return expectRevertReasonOrAlwaysFailingTransactionAsync( matchOrderTester.matchOrdersAndVerifyBalancesAsync( signedOrderLeft, signedOrderRight, @@ -680,6 +685,11 @@ describe('matchOrders', () => { erc20BalancesByOwner, erc721TokenIdsByOwner, ), + // We are assuming assetData fields of the right order are the + // reverse of the left order, rather than checking equality. This + // saves a bunch of gas, but as a result if the assetData fields are + // off then the failure ends up happening at signature validation + ContractLibErrors.InvalidSignature, ); }); @@ -702,7 +712,7 @@ describe('matchOrders', () => { feeRecipientAddress: feeRecipientAddressRight, }); // Match orders - return expectRevertOrAlwaysFailingTransactionAsync( + return expectRevertReasonOrAlwaysFailingTransactionAsync( matchOrderTester.matchOrdersAndVerifyBalancesAsync( signedOrderLeft, signedOrderRight, @@ -710,6 +720,7 @@ describe('matchOrders', () => { erc20BalancesByOwner, erc721TokenIdsByOwner, ), + ContractLibErrors.InvalidSignature, ); }); |