aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/exchange_wrapper_test.ts30
-rw-r--r--test/utils/order_factory.ts4
2 files changed, 30 insertions, 4 deletions
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts
index 370e741b4..48d10c1e4 100644
--- a/test/exchange_wrapper_test.ts
+++ b/test/exchange_wrapper_test.ts
@@ -4,13 +4,13 @@ import * as Web3 from 'web3';
import * as BigNumber from 'bignumber.js';
import {chaiSetup} from './utils/chai_setup';
import ChaiBigNumber = require('chai-bignumber');
-import * as chaiAsPromised from 'chai-as-promised';
import promisify = require('es6-promisify');
import {web3Factory} from './utils/web3_factory';
import {ZeroEx} from '../src/0x.js';
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
import {
Token,
+ Order,
SignedOrder,
SubscriptionOpts,
ExchangeEvents,
@@ -323,6 +323,34 @@ describe('ExchangeWrapper', () => {
});
});
});
+ describe('#cancelOrderAsync', () => {
+ let makerTokenAddress: string;
+ let takerTokenAddress: string;
+ let coinbase: string;
+ let makerAddress: string;
+ let takerAddress: string;
+ const fillableAmount = new BigNumber(5);
+ let signedOrder: SignedOrder;
+ let orderHashHex: string;
+ before(async () => {
+ [coinbase, makerAddress, takerAddress] = userAddresses;
+ const [makerToken, takerToken] = tokenUtils.getNonProtocolTokens();
+ makerTokenAddress = makerToken.address;
+ takerTokenAddress = takerToken.address;
+ signedOrder = await fillScenarios.createFillableSignedOrderAsync(
+ makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
+ );
+ orderHashHex = await zeroEx.getOrderHashHexAsync(signedOrder);
+ });
+ describe('successful cancels', () => {
+ it('should cancel an order', async () => {
+ const cancelAmount = new BigNumber(5);
+ await zeroEx.exchange.cancelOrderAsync(signedOrder, cancelAmount);
+ const cancelledAmount = await zeroEx.exchange.getCanceledTakerAmountAsync(orderHashHex);
+ expect(cancelledAmount).to.be.bignumber.equal(cancelAmount);
+ });
+ });
+ });
describe('tests that require partially filled order', () => {
let makerTokenAddress: string;
let takerTokenAddress: string;
diff --git a/test/utils/order_factory.ts b/test/utils/order_factory.ts
index 6f5fa7286..a1cc243c6 100644
--- a/test/utils/order_factory.ts
+++ b/test/utils/order_factory.ts
@@ -1,9 +1,7 @@
import * as _ from 'lodash';
import * as BigNumber from 'bignumber.js';
-import {SignedOrder, Token} from '../../src/types';
+import {SignedOrder} from '../../src/types';
import {ZeroEx} from '../../src/0x.js';
-import {constants} from './constants';
-import * as ExchangeArtifacts from '../../src/artifacts/Exchange.json';
export const orderFactory = {
async createSignedOrderAsync(