aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-07 20:40:28 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-07 20:40:28 +0800
commitc3cd5812e61359b18c469f70c9f0240db777e67a (patch)
tree829eb263a6fc8b036632ba0c769de0f67b78d209 /test
parent91101eb8ec4057617e644df4439c626093d4b3cc (diff)
downloaddexon-0x-contracts-c3cd5812e61359b18c469f70c9f0240db777e67a.tar.gz
dexon-0x-contracts-c3cd5812e61359b18c469f70c9f0240db777e67a.tar.zst
dexon-0x-contracts-c3cd5812e61359b18c469f70c9f0240db777e67a.zip
Refactor to use OrderCancellationRequest
Diffstat (limited to 'test')
-rw-r--r--test/exchange_wrapper_test.ts32
1 files changed, 21 insertions, 11 deletions
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts
index 6487ba98c..68224a68c 100644
--- a/test/exchange_wrapper_test.ts
+++ b/test/exchange_wrapper_test.ts
@@ -16,7 +16,7 @@ import {
ExchangeEvents,
ContractEvent,
DoneCallback,
- ExchangeContractErrs,
+ ExchangeContractErrs, OrderCancellationRequest,
} from '../src/types';
import {FillScenarios} from './utils/fill_scenarios';
import {TokenUtils} from './utils/token_utils';
@@ -377,34 +377,44 @@ describe('ExchangeWrapper', () => {
describe('#batchCancelOrderAsync', () => {
let anotherSignedOrder: SignedOrder;
let anotherOrderHashHex: string;
+ let cancelBatch: OrderCancellationRequest[];
beforeEach(async () => {
anotherSignedOrder = await fillScenarios.createFillableSignedOrderAsync(
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
);
anotherOrderHashHex = await zeroEx.getOrderHashHexAsync(anotherSignedOrder);
+ cancelBatch = [
+ {
+ order: signedOrder,
+ takerTokenCancelAmount: cancelAmount,
+ },
+ {
+ order: anotherSignedOrder,
+ takerTokenCancelAmount: cancelAmount,
+ },
+ ];
});
describe('failed batch cancels', () => {
- it('should throw when length of orders and cancelAmounts mismatch', async () => {
- return expect(zeroEx.exchange.batchCancelOrderAsync([signedOrder], []))
- .to.be.rejectedWith('orders and takerTokenCancelAmounts length mismatch. 1 != 0');
- });
it('should throw when orders are empty', async () => {
- return expect(zeroEx.exchange.batchCancelOrderAsync([], []))
+ return expect(zeroEx.exchange.batchCancelOrderAsync([]))
.to.be.rejectedWith('Can not cancel an empty batch');
});
it.only('should throw when orders have different makers', async () => {
const signedOrderWithADifferentMaker = await fillScenarios.createFillableSignedOrderAsync(
makerTokenAddress, takerTokenAddress, takerAddress, takerAddress, fillableAmount,
);
- return expect(zeroEx.exchange.batchCancelOrderAsync(
- [signedOrder, signedOrderWithADifferentMaker], [cancelAmount, cancelAmount]))
- .to.be.rejectedWith('Can not cancel orders from multiple makers in a single batch');
+ return expect(zeroEx.exchange.batchCancelOrderAsync([
+ cancelBatch[0],
+ {
+ order: signedOrderWithADifferentMaker,
+ takerTokenCancelAmount: cancelAmount,
+ },
+ ])).to.be.rejectedWith('Can not cancel orders from multiple makers in a single batch');
});
});
describe('successful batch cancels', () => {
it('should cancel a batch of orders', async () => {
- await zeroEx.exchange.batchCancelOrderAsync(
- [signedOrder, anotherSignedOrder], [cancelAmount, cancelAmount]);
+ await zeroEx.exchange.batchCancelOrderAsync(cancelBatch);
const cancelledAmount = await zeroEx.exchange.getCanceledTakerAmountAsync(orderHashHex);
const anotherCancelledAmount = await zeroEx.exchange.getCanceledTakerAmountAsync(
anotherOrderHashHex);