diff options
author | Fabio Berger <me@fabioberger.com> | 2017-06-02 15:43:03 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2017-06-02 15:43:03 +0800 |
commit | 707a5f55eb919b3460ae4ee7d58b9a0eaa56a07c (patch) | |
tree | 4e0eee1b8107a3e4b8136a3150ac5bda0e3d89c1 /test/utils | |
parent | 293ce6f4b2e495589ae3675eb293fb9948f22dbb (diff) | |
download | dexon-0x-contracts-707a5f55eb919b3460ae4ee7d58b9a0eaa56a07c.tar.gz dexon-0x-contracts-707a5f55eb919b3460ae4ee7d58b9a0eaa56a07c.tar.zst dexon-0x-contracts-707a5f55eb919b3460ae4ee7d58b9a0eaa56a07c.zip |
Write tests for getUnavailableTakerAmountAsync, getFilledTakerAmountAsync and getCanceledTakerAmountAsync
Diffstat (limited to 'test/utils')
-rw-r--r-- | test/utils/fill_scenarios.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/utils/fill_scenarios.ts b/test/utils/fill_scenarios.ts index ac233ad50..36656b455 100644 --- a/test/utils/fill_scenarios.ts +++ b/test/utils/fill_scenarios.ts @@ -26,4 +26,24 @@ export class FillScenarios { expirationUnixTimestampSec); return signedOrder; } + public async createPartiallyFilledSignedOrderAsync(makerTokenAddress: string, takerTokenAddress: string, + takerAddress: string, fillableAmount: BigNumber.BigNumber, + partialFillAmount: BigNumber.BigNumber) { + const prevSenderAccount = await this.zeroEx.getTransactionSenderAccountAsync(); + const [makerAddress] = this.userAddresses; + await this.zeroEx.token.setProxyAllowanceAsync(makerTokenAddress, makerAddress, fillableAmount); + await this.zeroEx.token.transferAsync(takerTokenAddress, makerAddress, takerAddress, fillableAmount); + await this.zeroEx.token.setProxyAllowanceAsync(takerTokenAddress, takerAddress, fillableAmount); + + const signedOrder = await orderFactory.createSignedOrderAsync(this.zeroEx, makerAddress, + takerAddress, fillableAmount, makerTokenAddress, fillableAmount, takerTokenAddress); + + this.zeroEx.setTransactionSenderAccount(takerAddress); + const shouldCheckTransfer = false; + await this.zeroEx.exchange.fillOrderAsync(signedOrder, partialFillAmount, shouldCheckTransfer); + + // Re-set sender account so as to avoid introducing side-effects + this.zeroEx.setTransactionSenderAccount(prevSenderAccount); + return signedOrder; + } } |