aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/test
diff options
context:
space:
mode:
authorLeonid <logvinov.leon@gmail.com>2017-11-28 05:53:21 +0800
committerGitHub <noreply@github.com>2017-11-28 05:53:21 +0800
commitcf0a8b2d0503f9d08ac789024d44b196613ecdc3 (patch)
tree75653154b85dd6df06da46af9411baf57c23367b /packages/0x.js/test
parent37f0051d8380279a1a882cdc724e54fc09117901 (diff)
parent4a17f5e82074b01e74ae6982e82419a037eebdb4 (diff)
downloaddexon-sol-tools-cf0a8b2d0503f9d08ac789024d44b196613ecdc3.tar
dexon-sol-tools-cf0a8b2d0503f9d08ac789024d44b196613ecdc3.tar.gz
dexon-sol-tools-cf0a8b2d0503f9d08ac789024d44b196613ecdc3.tar.bz2
dexon-sol-tools-cf0a8b2d0503f9d08ac789024d44b196613ecdc3.tar.lz
dexon-sol-tools-cf0a8b2d0503f9d08ac789024d44b196613ecdc3.tar.xz
dexon-sol-tools-cf0a8b2d0503f9d08ac789024d44b196613ecdc3.tar.zst
dexon-sol-tools-cf0a8b2d0503f9d08ac789024d44b196613ecdc3.zip
Merge branch 'development' into feature/passNetworkId
Diffstat (limited to 'packages/0x.js/test')
-rw-r--r--packages/0x.js/test/exchange_transfer_simulator_test.ts7
-rw-r--r--packages/0x.js/test/exchange_wrapper_test.ts2
-rw-r--r--packages/0x.js/test/order_state_watcher_test.ts18
-rw-r--r--packages/0x.js/test/order_validation_test.ts7
-rw-r--r--packages/0x.js/test/token_wrapper_test.ts2
5 files changed, 17 insertions, 19 deletions
diff --git a/packages/0x.js/test/exchange_transfer_simulator_test.ts b/packages/0x.js/test/exchange_transfer_simulator_test.ts
index 8e45b67a5..82cd54a34 100644
--- a/packages/0x.js/test/exchange_transfer_simulator_test.ts
+++ b/packages/0x.js/test/exchange_transfer_simulator_test.ts
@@ -3,6 +3,11 @@ import * as chai from 'chai';
import {ExchangeContractErrs, Token, ZeroEx} from '../src';
import {TradeSide, TransferType} from '../src/types';
+import {chaiSetup} from './utils/chai_setup';
+import {web3Factory} from './utils/web3_factory';
+import {ZeroEx, ExchangeContractErrs, Token} from '../src';
+import {TradeSide, TransferType, BlockParamLiteral} from '../src/types';
+import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
import {ExchangeTransferSimulator} from '../src/utils/exchange_transfer_simulator';
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
@@ -43,7 +48,7 @@ describe('ExchangeTransferSimulator', () => {
});
describe('#transferFromAsync', () => {
beforeEach(() => {
- exchangeTransferSimulator = new ExchangeTransferSimulator(zeroEx.token);
+ exchangeTransferSimulator = new ExchangeTransferSimulator(zeroEx.token, BlockParamLiteral.Latest);
});
it('throws if the user doesn\'t have enough allowance', async () => {
return expect(exchangeTransferSimulator.transferFromAsync(
diff --git a/packages/0x.js/test/exchange_wrapper_test.ts b/packages/0x.js/test/exchange_wrapper_test.ts
index 6fe52a75a..f6c823cc4 100644
--- a/packages/0x.js/test/exchange_wrapper_test.ts
+++ b/packages/0x.js/test/exchange_wrapper_test.ts
@@ -760,7 +760,7 @@ describe('ExchangeWrapper', () => {
const fillableAmount = new BigNumber(5);
const shouldThrowOnInsufficientBalanceOrAllowance = true;
const subscriptionOpts: SubscriptionOpts = {
- fromBlock: BlockParamLiteral.Earliest,
+ fromBlock: 0,
toBlock: BlockParamLiteral.Latest,
};
let txHash: string;
diff --git a/packages/0x.js/test/order_state_watcher_test.ts b/packages/0x.js/test/order_state_watcher_test.ts
index ba37d1ce5..1e5bc1a35 100644
--- a/packages/0x.js/test/order_state_watcher_test.ts
+++ b/packages/0x.js/test/order_state_watcher_test.ts
@@ -185,16 +185,12 @@ describe('OrderStateWatcher', () => {
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
zeroEx.orderStateWatcher.addOrder(signedOrder);
- let eventCount = 0;
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
- eventCount++;
expect(orderState.isValid).to.be.false();
const invalidOrderState = orderState as OrderStateInvalid;
expect(invalidOrderState.orderHash).to.be.equal(orderHash);
expect(invalidOrderState.error).to.be.equal(ExchangeContractErrs.OrderRemainingFillAmountZero);
- if (eventCount === 2) {
- done();
- }
+ done();
});
zeroEx.orderStateWatcher.subscribe(callback);
@@ -217,9 +213,7 @@ describe('OrderStateWatcher', () => {
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
zeroEx.orderStateWatcher.addOrder(signedOrder);
- let eventCount = 0;
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
- eventCount++;
expect(orderState.isValid).to.be.true();
const validOrderState = orderState as OrderStateValid;
expect(validOrderState.orderHash).to.be.equal(orderHash);
@@ -231,9 +225,7 @@ describe('OrderStateWatcher', () => {
expect(orderRelevantState.remainingFillableTakerTokenAmount).to.be.bignumber.equal(
remainingFillable);
expect(orderRelevantState.makerBalance).to.be.bignumber.equal(remainingMakerBalance);
- if (eventCount === 2) {
- done();
- }
+ done();
});
zeroEx.orderStateWatcher.subscribe(callback);
const shouldThrowOnInsufficientBalanceOrAllowance = true;
@@ -272,9 +264,7 @@ describe('OrderStateWatcher', () => {
const fillAmountInBaseUnits = ZeroEx.toBaseUnitAmount(new BigNumber(2), decimals);
const orderHash = ZeroEx.getOrderHashHex(signedOrder);
zeroEx.orderStateWatcher.addOrder(signedOrder);
- let eventCount = 0;
const callback = reportCallbackErrors(done)((orderState: OrderState) => {
- eventCount++;
expect(orderState.isValid).to.be.true();
const validOrderState = orderState as OrderStateValid;
expect(validOrderState.orderHash).to.be.equal(orderHash);
@@ -283,9 +273,7 @@ describe('OrderStateWatcher', () => {
ZeroEx.toBaseUnitAmount(new BigNumber(16), decimals));
expect(orderRelevantState.remainingFillableTakerTokenAmount).to.be.bignumber.equal(
ZeroEx.toBaseUnitAmount(new BigNumber(8), decimals));
- if (eventCount === 2) {
- done();
- }
+ done();
});
zeroEx.orderStateWatcher.subscribe(callback);
const shouldThrowOnInsufficientBalanceOrAllowance = true;
diff --git a/packages/0x.js/test/order_validation_test.ts b/packages/0x.js/test/order_validation_test.ts
index e210c04a8..3725c85da 100644
--- a/packages/0x.js/test/order_validation_test.ts
+++ b/packages/0x.js/test/order_validation_test.ts
@@ -8,6 +8,11 @@ import {TradeSide, TransferType} from '../src/types';
import {ExchangeTransferSimulator} from '../src/utils/exchange_transfer_simulator';
import {OrderValidationUtils} from '../src/utils/order_validation_utils';
+import {chaiSetup} from './utils/chai_setup';
+import {web3Factory} from './utils/web3_factory';
+import {ZeroEx, SignedOrder, Token, ExchangeContractErrs, ZeroExError} from '../src';
+import {TradeSide, TransferType, BlockParamLiteral} from '../src/types';
+import {TokenUtils} from './utils/token_utils';
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
import {chaiSetup} from './utils/chai_setup';
import {constants} from './utils/constants';
@@ -221,7 +226,7 @@ describe('OrderValidation', () => {
return Sinon.match((value: BigNumber) => value.eq(expected));
};
beforeEach('create exchangeTransferSimulator', async () => {
- exchangeTransferSimulator = new ExchangeTransferSimulator(zeroEx.token);
+ exchangeTransferSimulator = new ExchangeTransferSimulator(zeroEx.token, BlockParamLiteral.Latest);
transferFromAsync = Sinon.spy();
exchangeTransferSimulator.transferFromAsync = transferFromAsync as any;
});
diff --git a/packages/0x.js/test/token_wrapper_test.ts b/packages/0x.js/test/token_wrapper_test.ts
index d0ca0144a..cc61c2324 100644
--- a/packages/0x.js/test/token_wrapper_test.ts
+++ b/packages/0x.js/test/token_wrapper_test.ts
@@ -434,7 +434,7 @@ describe('TokenWrapper', () => {
let tokenAddress: string;
let tokenTransferProxyAddress: string;
const subscriptionOpts: SubscriptionOpts = {
- fromBlock: BlockParamLiteral.Earliest,
+ fromBlock: 0,
toBlock: BlockParamLiteral.Latest,
};
let txHash: string;