From fb55def54f44413a8b0a7f001fb18d6eac89e422 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 15 Jun 2018 00:03:00 +0200 Subject: Add ability to tweak the relevant balances/allowances for the maker and taker for a fillScenario. Convert more of the core tests to the declarative form. --- packages/contracts/test/exchange/fill_order.ts | 57 ++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'packages/contracts/test/exchange/fill_order.ts') diff --git a/packages/contracts/test/exchange/fill_order.ts b/packages/contracts/test/exchange/fill_order.ts index 2498ee27e..5e8dd6ffc 100644 --- a/packages/contracts/test/exchange/fill_order.ts +++ b/packages/contracts/test/exchange/fill_order.ts @@ -13,6 +13,7 @@ import { OrderScenario, TakerAssetFillAmountScenario, TakerScenario, + TokenAmountScenario, } from '../../src/utils/types'; chaiSetup.configure(); @@ -31,6 +32,18 @@ const defaultFillScenario = { takerAssetDataScenario: AssetDataScenario.ERC20NonZRXEighteenDecimals, }, takerAssetFillAmountScenario: TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount, + makerStateScenario: { + traderAssetBalance: TokenAmountScenario.Higher, + traderAssetAllowance: TokenAmountScenario.Higher, + zrxFeeBalance: TokenAmountScenario.Higher, + zrxFeeAllowance: TokenAmountScenario.Higher, + }, + takerStateScenario: { + traderAssetBalance: TokenAmountScenario.Higher, + traderAssetAllowance: TokenAmountScenario.Higher, + zrxFeeBalance: TokenAmountScenario.Higher, + zrxFeeAllowance: TokenAmountScenario.Higher, + }, }; describe('FillOrder Tests', () => { @@ -144,6 +157,50 @@ describe('FillOrder Tests', () => { }; await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario); }); + + it('should throw if maker erc20Balances are too low to fill order', async () => { + const fillScenario = { + ...defaultFillScenario, + makerStateScenario: { + ...defaultFillScenario.makerStateScenario, + traderAssetBalance: TokenAmountScenario.TooLow, + }, + }; + await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario); + }); + + it('should throw if taker erc20Balances are too low to fill order', async () => { + const fillScenario = { + ...defaultFillScenario, + takerStateScenario: { + ...defaultFillScenario.makerStateScenario, + traderAssetBalance: TokenAmountScenario.TooLow, + }, + }; + await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario); + }); + + it('should throw if maker allowances are too low to fill order', async () => { + const fillScenario = { + ...defaultFillScenario, + makerStateScenario: { + ...defaultFillScenario.makerStateScenario, + traderAssetAllowance: TokenAmountScenario.TooLow, + }, + }; + await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario); + }); + + it('should throw if taker allowances are too low to fill order', async () => { + const fillScenario = { + ...defaultFillScenario, + takerStateScenario: { + ...defaultFillScenario.makerStateScenario, + traderAssetAllowance: TokenAmountScenario.TooLow, + }, + }; + await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario); + }); }); describe('Testing Exchange of ERC721 Tokens', () => { -- cgit v1.2.3