aboutsummaryrefslogtreecommitdiffstats
path: root/test/exchange_wrapper_test.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-09 00:14:29 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-09 00:14:29 +0800
commit6eb192f0ea056bc84e04df1845f484a906ad392c (patch)
tree643d52ce23bcc7fd34499c245a4ae335432399ea /test/exchange_wrapper_test.ts
parentcd25d38118de90f8282dc8e5e2b4ffb02fde9990 (diff)
downloaddexon-sol-tools-6eb192f0ea056bc84e04df1845f484a906ad392c.tar
dexon-sol-tools-6eb192f0ea056bc84e04df1845f484a906ad392c.tar.gz
dexon-sol-tools-6eb192f0ea056bc84e04df1845f484a906ad392c.tar.bz2
dexon-sol-tools-6eb192f0ea056bc84e04df1845f484a906ad392c.tar.lz
dexon-sol-tools-6eb192f0ea056bc84e04df1845f484a906ad392c.tar.xz
dexon-sol-tools-6eb192f0ea056bc84e04df1845f484a906ad392c.tar.zst
dexon-sol-tools-6eb192f0ea056bc84e04df1845f484a906ad392c.zip
Add tests for fillOrdersUpTo
Diffstat (limited to 'test/exchange_wrapper_test.ts')
-rw-r--r--test/exchange_wrapper_test.ts34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts
index e3d8be1c0..4a1dbaed6 100644
--- a/test/exchange_wrapper_test.ts
+++ b/test/exchange_wrapper_test.ts
@@ -367,6 +367,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 = fillUpToAmount.minus(filledAmount);
+ expect(anotherFilledAmount).to.be.bignumber.equal(remainingFillAmount);
+ });
+ });
+ });
});
describe('cancel order(s)', () => {
let makerTokenAddress: string;