diff options
author | Leonid <logvinov.leon@gmail.com> | 2017-06-23 04:50:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-23 04:50:35 +0800 |
commit | c52d6753cefcc6b55a6683e5a1c45ed62f698dc3 (patch) | |
tree | da804f637b18b8589be98d81b34b26cbfc2b9032 /test | |
parent | 49e43c98767666fcf457edfe2f3cbe098d12b6a5 (diff) | |
parent | e5785532ed1f4cada70db7815a44ffdd005077f5 (diff) | |
download | dexon-sol-tools-c52d6753cefcc6b55a6683e5a1c45ed62f698dc3.tar dexon-sol-tools-c52d6753cefcc6b55a6683e5a1c45ed62f698dc3.tar.gz dexon-sol-tools-c52d6753cefcc6b55a6683e5a1c45ed62f698dc3.tar.bz2 dexon-sol-tools-c52d6753cefcc6b55a6683e5a1c45ed62f698dc3.tar.lz dexon-sol-tools-c52d6753cefcc6b55a6683e5a1c45ed62f698dc3.tar.xz dexon-sol-tools-c52d6753cefcc6b55a6683e5a1c45ed62f698dc3.tar.zst dexon-sol-tools-c52d6753cefcc6b55a6683e5a1c45ed62f698dc3.zip |
Merge pull request #72 from 0xProject/fill-order-amuont
Return filledAmount from fillOrderAsync
Diffstat (limited to 'test')
-rw-r--r-- | test/exchange_wrapper_test.ts | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts index e4b2e3f86..211c2819c 100644 --- a/test/exchange_wrapper_test.ts +++ b/test/exchange_wrapper_test.ts @@ -339,6 +339,34 @@ describe('ExchangeWrapper', () => { expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress)) .to.be.bignumber.equal(fillableAmount.minus(partialFillAmount)); }); + it('should return filled amount', async () => { + const signedOrder = await fillScenarios.createFillableSignedOrderAsync( + makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount, + ); + const partialFillAmount = new BigNumber(3); + const filledAmount = await zeroEx.exchange.fillOrderAsync( + signedOrder, partialFillAmount, shouldCheckTransfer, takerAddress); + expect(filledAmount).to.be.bignumber.equal(partialFillAmount); + }); + it('should return the partially filled amount \ + if the fill amount specified is greater then the amount available', async () => { + const signedOrder = await fillScenarios.createFillableSignedOrderAsync( + makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount, + ); + const partialFillAmount = new BigNumber(3); + await zeroEx.exchange.fillOrderAsync( + signedOrder, partialFillAmount, shouldCheckTransfer, takerAddress); + const missingBalance = new BigNumber(1); + const totalBalance = partialFillAmount.plus(missingBalance); + await zeroEx.token.transferAsync(takerTokenAddress, coinbase, takerAddress, missingBalance); + await zeroEx.token.setProxyAllowanceAsync(takerTokenAddress, takerAddress, totalBalance); + await zeroEx.token.transferAsync(makerTokenAddress, coinbase, makerAddress, missingBalance); + await zeroEx.token.setProxyAllowanceAsync(makerTokenAddress, makerAddress, totalBalance); + const remainingFillAmount = fillableAmount.minus(partialFillAmount); + const filledAmount = await zeroEx.exchange.fillOrderAsync( + signedOrder, partialFillAmount, shouldCheckTransfer, takerAddress); + expect(filledAmount).to.be.bignumber.equal(remainingFillAmount); + }); it('should fill the valid orders with fees', async () => { const makerFee = new BigNumber(1); const takerFee = new BigNumber(2); @@ -424,6 +452,12 @@ describe('ExchangeWrapper', () => { const remainingFillAmount = fillableAmount.minus(1); expect(anotherFilledAmount).to.be.bignumber.equal(remainingFillAmount); }); + it('should return filled amount', async () => { + const filledTakerTokenAmount = await zeroEx.exchange.fillOrdersUpToAsync( + signedOrders, fillUpToAmount, shouldCheckTransfer, takerAddress, + ); + expect(filledTakerTokenAmount).to.be.bignumber.equal(fillUpToAmount); + }); }); }); }); @@ -476,6 +510,10 @@ describe('ExchangeWrapper', () => { const cancelledAmount = await zeroEx.exchange.getCanceledTakerAmountAsync(orderHashHex); expect(cancelledAmount).to.be.bignumber.equal(cancelAmount); }); + it('should return cancelled amount', async () => { + const cancelledAmount = await zeroEx.exchange.cancelOrderAsync(signedOrder, cancelAmount); + expect(cancelledAmount).to.be.bignumber.equal(cancelAmount); + }); }); }); describe('#batchCancelOrderAsync', () => { |