diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-01-16 18:08:17 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-01-16 18:08:17 +0800 |
commit | 8b81ea162fd32df0dc2dcbdbc47be0e1bb09ea0f (patch) | |
tree | 71c398d0a2904fda7cba657d9d3c00558b71b791 /packages/0x.js | |
parent | 62e3feeb94bcbd8dd32cba24a0270b4afabce7e8 (diff) | |
download | dexon-sol-tools-8b81ea162fd32df0dc2dcbdbc47be0e1bb09ea0f.tar dexon-sol-tools-8b81ea162fd32df0dc2dcbdbc47be0e1bb09ea0f.tar.gz dexon-sol-tools-8b81ea162fd32df0dc2dcbdbc47be0e1bb09ea0f.tar.bz2 dexon-sol-tools-8b81ea162fd32df0dc2dcbdbc47be0e1bb09ea0f.tar.lz dexon-sol-tools-8b81ea162fd32df0dc2dcbdbc47be0e1bb09ea0f.tar.xz dexon-sol-tools-8b81ea162fd32df0dc2dcbdbc47be0e1bb09ea0f.tar.zst dexon-sol-tools-8b81ea162fd32df0dc2dcbdbc47be0e1bb09ea0f.zip |
Add a regression test for fillUpToValidation
Diffstat (limited to 'packages/0x.js')
-rw-r--r-- | packages/0x.js/test/exchange_wrapper_test.ts | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/packages/0x.js/test/exchange_wrapper_test.ts b/packages/0x.js/test/exchange_wrapper_test.ts index 39a5be61d..32f8514d9 100644 --- a/packages/0x.js/test/exchange_wrapper_test.ts +++ b/packages/0x.js/test/exchange_wrapper_test.ts @@ -536,7 +536,24 @@ describe('ExchangeWrapper', () => { ), ).to.be.rejectedWith(ExchangeContractErrs.BatchOrdersMustHaveAtLeastOneItem); }); - it('should successfully fill up to specified amount', async () => { + it('should successfully fill up to specified amount when all orders are fully funded', async () => { + const txHash = await zeroEx.exchange.fillOrdersUpToAsync( + signedOrders, + fillUpToAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + takerAddress, + ); + await zeroEx.awaitTransactionMinedAsync(txHash); + 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); + }); + it('should successfully fill up to specified amount even if filling all orders will fail', async () => { + const missingBalance = new BigNumber(1); // User will still have enough balance to fill up to 9, + // but won't have 10 to fully fill all orders in a batch. + await zeroEx.token.transferAsync(makerTokenAddress, makerAddress, coinbase, missingBalance); const txHash = await zeroEx.exchange.fillOrdersUpToAsync( signedOrders, fillUpToAmount, |