diff options
author | Leonid <logvinov.leon@gmail.com> | 2017-06-09 22:58:52 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-09 22:58:52 +0800 |
commit | 3a9d07c40ce2e26203962487036132d6357ec530 (patch) | |
tree | 87a2416fa3c0506ce0fffe2021de05069db4fbc2 /test/exchange_wrapper_test.ts | |
parent | 389894088d2372e1eb9bf4d39bde2efe8ab38713 (diff) | |
parent | ba9a0b0bb9e87e69c818a5fe73183d8d22476948 (diff) | |
download | dexon-sol-tools-3a9d07c40ce2e26203962487036132d6357ec530.tar dexon-sol-tools-3a9d07c40ce2e26203962487036132d6357ec530.tar.gz dexon-sol-tools-3a9d07c40ce2e26203962487036132d6357ec530.tar.bz2 dexon-sol-tools-3a9d07c40ce2e26203962487036132d6357ec530.tar.lz dexon-sol-tools-3a9d07c40ce2e26203962487036132d6357ec530.tar.xz dexon-sol-tools-3a9d07c40ce2e26203962487036132d6357ec530.tar.zst dexon-sol-tools-3a9d07c40ce2e26203962487036132d6357ec530.zip |
Merge pull request #49 from 0xProject/fillOrderUpToAsync
Implement fillOrderUpToAsync
Diffstat (limited to 'test/exchange_wrapper_test.ts')
-rw-r--r-- | test/exchange_wrapper_test.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts index 2cd8af7f0..f159de759 100644 --- a/test/exchange_wrapper_test.ts +++ b/test/exchange_wrapper_test.ts @@ -392,6 +392,40 @@ describe('ExchangeWrapper', () => { }); }); }); + describe('#fillOrdersUpTo', () => { + let signedOrder: SignedOrder; + let signedOrderHashHex: string; + let anotherSignedOrder: SignedOrder; + let anotherOrderHashHex: string; + let signedOrders: SignedOrder[]; + const fillUpToAmount = fillableAmount.plus(fillableAmount).minus(1); + beforeEach(async () => { + signedOrder = await fillScenarios.createFillableSignedOrderAsync( + makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount, + ); + signedOrderHashHex = await zeroEx.getOrderHashHexAsync(signedOrder); + anotherSignedOrder = await fillScenarios.createFillableSignedOrderAsync( + makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount, + ); + anotherOrderHashHex = await zeroEx.getOrderHashHexAsync(anotherSignedOrder); + signedOrders = [signedOrder, anotherSignedOrder]; + }); + describe('successful batch fills', () => { + it('should no-op for an empty batch', async () => { + await zeroEx.exchange.fillOrdersUpToAsync([], fillUpToAmount, shouldCheckTransfer, takerAddress); + }); + it('should successfully fill up to specified amount', async () => { + await zeroEx.exchange.fillOrdersUpToAsync( + signedOrders, fillUpToAmount, shouldCheckTransfer, takerAddress, + ); + const filledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(signedOrderHashHex); + const anotherFilledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(anotherOrderHashHex); + expect(filledAmount).to.be.bignumber.equal(fillableAmount); + const remainingFillAmount = fillableAmount.minus(1); + expect(anotherFilledAmount).to.be.bignumber.equal(remainingFillAmount); + }); + }); + }); }); describe('cancel order(s)', () => { let makerTokenAddress: string; |