aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/test
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-11-23 02:15:31 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-11-24 05:13:36 +0800
commit66aaceea915b6412c8ff8bcb5001363da8aaca39 (patch)
treea636673a2fef8a6db85918e1b391fe75e3fb0a1d /packages/0x.js/test
parent4fe28ec53c4e84544c3c21853dff57c4c6a4e45d (diff)
downloaddexon-sol-tools-66aaceea915b6412c8ff8bcb5001363da8aaca39.tar
dexon-sol-tools-66aaceea915b6412c8ff8bcb5001363da8aaca39.tar.gz
dexon-sol-tools-66aaceea915b6412c8ff8bcb5001363da8aaca39.tar.bz2
dexon-sol-tools-66aaceea915b6412c8ff8bcb5001363da8aaca39.tar.lz
dexon-sol-tools-66aaceea915b6412c8ff8bcb5001363da8aaca39.tar.xz
dexon-sol-tools-66aaceea915b6412c8ff8bcb5001363da8aaca39.tar.zst
dexon-sol-tools-66aaceea915b6412c8ff8bcb5001363da8aaca39.zip
Cleanup order watcher from redundant asyncs
Diffstat (limited to 'packages/0x.js/test')
-rw-r--r--packages/0x.js/test/expiration_watcher_test.ts8
-rw-r--r--packages/0x.js/test/order_state_watcher_test.ts32
-rw-r--r--packages/0x.js/test/order_validation_test.ts2
3 files changed, 23 insertions, 19 deletions
diff --git a/packages/0x.js/test/expiration_watcher_test.ts b/packages/0x.js/test/expiration_watcher_test.ts
index 0f2470070..5b8848eba 100644
--- a/packages/0x.js/test/expiration_watcher_test.ts
+++ b/packages/0x.js/test/expiration_watcher_test.ts
@@ -7,6 +7,7 @@ import BigNumber from 'bignumber.js';
import {chaiSetup} from './utils/chai_setup';
import {web3Factory} from './utils/web3_factory';
import {utils} from '../src/utils/utils';
+import {constants} from '../src/utils/constants';
import {Web3Wrapper} from '../src/web3_wrapper';
import {TokenUtils} from './utils/token_utils';
import {ExpirationWatcher} from '../src/order_watcher/expiration_watcher';
@@ -41,8 +42,11 @@ describe('ExpirationWatcher', () => {
let expirationWatcher: ExpirationWatcher;
before(async () => {
web3 = web3Factory.create();
- zeroEx = new ZeroEx(web3.currentProvider);
- exchangeContractAddress = await zeroEx.exchange.getContractAddressAsync();
+ const config = {
+ networkId: constants.TESTRPC_NETWORK_ID,
+ };
+ zeroEx = new ZeroEx(web3.currentProvider, config);
+ exchangeContractAddress = await zeroEx.exchange.getContractAddress();
userAddresses = await zeroEx.getAvailableAddressesAsync();
tokens = await zeroEx.tokenRegistry.getTokensAsync();
tokenUtils = new TokenUtils(tokens);
diff --git a/packages/0x.js/test/order_state_watcher_test.ts b/packages/0x.js/test/order_state_watcher_test.ts
index fd94a3df6..2c7c2a971 100644
--- a/packages/0x.js/test/order_state_watcher_test.ts
+++ b/packages/0x.js/test/order_state_watcher_test.ts
@@ -78,13 +78,13 @@ describe('OrderStateWatcher', () => {
makerToken.address, takerToken.address, maker, taker, fillableAmount,
);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
- await zeroEx.orderStateWatcher.addOrderAsync(signedOrder);
+ zeroEx.orderStateWatcher.addOrder(signedOrder);
expect((zeroEx.orderStateWatcher as any)._orderByOrderHash).to.include({
[orderHash]: signedOrder,
});
let dependentOrderHashes = (zeroEx.orderStateWatcher as any)._dependentOrderHashes;
expect(dependentOrderHashes[signedOrder.maker][signedOrder.makerTokenAddress]).to.have.keys(orderHash);
- await zeroEx.orderStateWatcher.removeOrderAsync(orderHash);
+ zeroEx.orderStateWatcher.removeOrder(orderHash);
expect((zeroEx.orderStateWatcher as any)._orderByOrderHash).to.not.include({
[orderHash]: signedOrder,
});
@@ -97,7 +97,7 @@ describe('OrderStateWatcher', () => {
);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
const nonExistentOrderHash = `0x${orderHash.substr(2).split('').reverse().join('')}`;
- await zeroEx.orderStateWatcher.removeOrderAsync(nonExistentOrderHash);
+ zeroEx.orderStateWatcher.removeOrder(nonExistentOrderHash);
});
});
describe('#subscribe', async () => {
@@ -114,7 +114,7 @@ describe('OrderStateWatcher', () => {
afterEach(async () => {
zeroEx.orderStateWatcher.unsubscribe();
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
- await zeroEx.orderStateWatcher.removeOrderAsync(orderHash);
+ zeroEx.orderStateWatcher.removeOrder(orderHash);
});
it('should emit orderStateInvalid when maker allowance set to 0 for watched order', (done: DoneCallback) => {
(async () => {
@@ -122,7 +122,7 @@ describe('OrderStateWatcher', () => {
makerToken.address, takerToken.address, maker, taker, fillableAmount,
);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
- await zeroEx.orderStateWatcher.addOrderAsync(signedOrder);
+ zeroEx.orderStateWatcher.addOrder(signedOrder);
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
expect(orderState.isValid).to.be.false();
const invalidOrderState = orderState as OrderStateInvalid;
@@ -140,7 +140,7 @@ describe('OrderStateWatcher', () => {
makerToken.address, takerToken.address, maker, taker, fillableAmount,
);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
- await zeroEx.orderStateWatcher.addOrderAsync(signedOrder);
+ zeroEx.orderStateWatcher.addOrder(signedOrder);
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
throw new Error('OrderState callback fired for irrelevant order');
});
@@ -161,7 +161,7 @@ describe('OrderStateWatcher', () => {
makerToken.address, takerToken.address, maker, taker, fillableAmount,
);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
- await zeroEx.orderStateWatcher.addOrderAsync(signedOrder);
+ zeroEx.orderStateWatcher.addOrder(signedOrder);
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
expect(orderState.isValid).to.be.false();
const invalidOrderState = orderState as OrderStateInvalid;
@@ -181,7 +181,7 @@ describe('OrderStateWatcher', () => {
makerToken.address, takerToken.address, maker, taker, fillableAmount,
);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
- await zeroEx.orderStateWatcher.addOrderAsync(signedOrder);
+ zeroEx.orderStateWatcher.addOrder(signedOrder);
let eventCount = 0;
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
@@ -213,7 +213,7 @@ describe('OrderStateWatcher', () => {
const fillAmountInBaseUnits = new BigNumber(2);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
- await zeroEx.orderStateWatcher.addOrderAsync(signedOrder);
+ zeroEx.orderStateWatcher.addOrder(signedOrder);
let eventCount = 0;
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
@@ -248,7 +248,7 @@ describe('OrderStateWatcher', () => {
makerToken.address, takerToken.address, makerFee, takerFee, maker, taker, fillableAmount,
taker);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
- await zeroEx.orderStateWatcher.addOrderAsync(signedOrder);
+ zeroEx.orderStateWatcher.addOrder(signedOrder);
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
done();
});
@@ -269,7 +269,7 @@ describe('OrderStateWatcher', () => {
const takerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, taker);
const fillAmountInBaseUnits = ZeroEx.toBaseUnitAmount(new BigNumber(2), decimals);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
- await zeroEx.orderStateWatcher.addOrderAsync(signedOrder);
+ zeroEx.orderStateWatcher.addOrder(signedOrder);
let eventCount = 0;
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
eventCount++;
@@ -301,7 +301,7 @@ describe('OrderStateWatcher', () => {
const makerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, maker);
const changedMakerApprovalAmount = ZeroEx.toBaseUnitAmount(new BigNumber(3), decimals);
- await zeroEx.orderStateWatcher.addOrderAsync(signedOrder);
+ zeroEx.orderStateWatcher.addOrder(signedOrder);
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
const validOrderState = orderState as OrderStateValid;
@@ -326,7 +326,7 @@ describe('OrderStateWatcher', () => {
const remainingAmount = ZeroEx.toBaseUnitAmount(new BigNumber(1), decimals);
const transferAmount = makerBalance.sub(remainingAmount);
- await zeroEx.orderStateWatcher.addOrderAsync(signedOrder);
+ zeroEx.orderStateWatcher.addOrder(signedOrder);
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
expect(orderState.isValid).to.be.true();
@@ -432,7 +432,7 @@ describe('OrderStateWatcher', () => {
makerToken.address, takerToken.address, maker, taker, fillableAmount,
);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
- await zeroEx.orderStateWatcher.addOrderAsync(signedOrder);
+ zeroEx.orderStateWatcher.addOrder(signedOrder);
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
expect(orderState.isValid).to.be.false();
@@ -454,7 +454,7 @@ describe('OrderStateWatcher', () => {
makerToken.address, takerToken.address, maker, taker, fillableAmount,
);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
- await zeroEx.orderStateWatcher.addOrderAsync(signedOrder);
+ zeroEx.orderStateWatcher.addOrder(signedOrder);
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
expect(orderState.isValid).to.be.false();
@@ -480,7 +480,7 @@ describe('OrderStateWatcher', () => {
const cancelAmountInBaseUnits = new BigNumber(2);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
- await zeroEx.orderStateWatcher.addOrderAsync(signedOrder);
+ zeroEx.orderStateWatcher.addOrder(signedOrder);
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
expect(orderState.isValid).to.be.true();
diff --git a/packages/0x.js/test/order_validation_test.ts b/packages/0x.js/test/order_validation_test.ts
index 7345b1094..811cd48c4 100644
--- a/packages/0x.js/test/order_validation_test.ts
+++ b/packages/0x.js/test/order_validation_test.ts
@@ -41,7 +41,7 @@ describe('OrderValidation', () => {
before(async () => {
web3 = web3Factory.create();
zeroEx = new ZeroEx(web3.currentProvider, config);
- exchangeContractAddress = await zeroEx.exchange.getContractAddressAsync();
+ exchangeContractAddress = zeroEx.exchange.getContractAddress();
userAddresses = await zeroEx.getAvailableAddressesAsync();
[coinbase, makerAddress, takerAddress, feeRecipient] = userAddresses;
tokens = await zeroEx.tokenRegistry.getTokensAsync();