aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-watcher/test
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-10-05 07:33:10 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-10-16 04:37:56 +0800
commit29063cab186196dc7051ca16ca9409e8619c6673 (patch)
tree39b285cde57c1df15aecae9649aaaae66f49f857 /packages/order-watcher/test
parent3da032fb24a7b3d27fd388ce4fbc6bd194971201 (diff)
downloaddexon-sol-tools-29063cab186196dc7051ca16ca9409e8619c6673.tar
dexon-sol-tools-29063cab186196dc7051ca16ca9409e8619c6673.tar.gz
dexon-sol-tools-29063cab186196dc7051ca16ca9409e8619c6673.tar.bz2
dexon-sol-tools-29063cab186196dc7051ca16ca9409e8619c6673.tar.lz
dexon-sol-tools-29063cab186196dc7051ca16ca9409e8619c6673.tar.xz
dexon-sol-tools-29063cab186196dc7051ca16ca9409e8619c6673.tar.zst
dexon-sol-tools-29063cab186196dc7051ca16ca9409e8619c6673.zip
update order-watcher to use new artifacts and abi-gen wrappers packages
Diffstat (limited to 'packages/order-watcher/test')
-rw-r--r--packages/order-watcher/test/expiration_watcher_test.ts19
-rw-r--r--packages/order-watcher/test/global_hooks.ts5
-rw-r--r--packages/order-watcher/test/order_watcher_test.ts24
-rw-r--r--packages/order-watcher/test/utils/token_utils.ts34
4 files changed, 22 insertions, 60 deletions
diff --git a/packages/order-watcher/test/expiration_watcher_test.ts b/packages/order-watcher/test/expiration_watcher_test.ts
index ea9923487..056e53988 100644
--- a/packages/order-watcher/test/expiration_watcher_test.ts
+++ b/packages/order-watcher/test/expiration_watcher_test.ts
@@ -1,7 +1,7 @@
-import { ContractWrappers } from '@0xproject/contract-wrappers';
import { tokenUtils } from '@0xproject/contract-wrappers/lib/test/utils/token_utils';
import { BlockchainLifecycle, callbackErrorReporter } from '@0xproject/dev-utils';
import { FillScenarios } from '@0xproject/fill-scenarios';
+import { getContractAddresses } from '@0xproject/migrations';
import { assetDataUtils, orderHashUtils } from '@0xproject/order-utils';
import { DoneCallback } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
@@ -14,7 +14,6 @@ import { ExpirationWatcher } from '../src/order_watcher/expiration_watcher';
import { utils } from '../src/utils/utils';
import { chaiSetup } from './utils/chai_setup';
-import { constants } from './utils/constants';
import { provider, web3Wrapper } from './utils/web3_wrapper';
chaiSetup.configure();
@@ -23,14 +22,8 @@ const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
const MILISECONDS_IN_SECOND = 1000;
describe('ExpirationWatcher', () => {
- const config = {
- networkId: constants.TESTRPC_NETWORK_ID,
- };
- const contractWrappers = new ContractWrappers(provider, config);
let userAddresses: string[];
- let zrxTokenAddress: string;
let fillScenarios: FillScenarios;
- const exchangeContractAddress = contractWrappers.exchange.getContractAddress();
let makerAssetData: string;
let takerAssetData: string;
let coinbase: string;
@@ -43,15 +36,15 @@ describe('ExpirationWatcher', () => {
let expirationWatcher: ExpirationWatcher;
before(async () => {
await blockchainLifecycle.startAsync();
+ const contractAddresses = getContractAddresses();
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
- zrxTokenAddress = tokenUtils.getProtocolTokenAddress();
fillScenarios = new FillScenarios(
provider,
userAddresses,
- zrxTokenAddress,
- exchangeContractAddress,
- contractWrappers.erc20Proxy.getContractAddress(),
- contractWrappers.erc721Proxy.getContractAddress(),
+ contractAddresses.zrxToken,
+ contractAddresses.exchange,
+ contractAddresses.erc20Proxy,
+ contractAddresses.erc721Proxy,
);
[coinbase, makerAddress, takerAddress, feeRecipient] = userAddresses;
const [makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses();
diff --git a/packages/order-watcher/test/global_hooks.ts b/packages/order-watcher/test/global_hooks.ts
index 99df04a51..49340f9e1 100644
--- a/packages/order-watcher/test/global_hooks.ts
+++ b/packages/order-watcher/test/global_hooks.ts
@@ -1,5 +1,5 @@
import { devConstants } from '@0xproject/dev-utils';
-import { runV2MigrationsAsync } from '@0xproject/migrations';
+import { runMigrationsAsync } from '@0xproject/migrations';
import { provider } from './utils/web3_wrapper';
@@ -12,6 +12,5 @@ before('migrate contracts', async function(): Promise<void> {
gas: devConstants.GAS_LIMIT,
from: devConstants.TESTRPC_FIRST_ADDRESS,
};
- const artifactsDir = `src/artifacts`;
- await runV2MigrationsAsync(provider, artifactsDir, txDefaults);
+ await runMigrationsAsync(provider, txDefaults);
});
diff --git a/packages/order-watcher/test/order_watcher_test.ts b/packages/order-watcher/test/order_watcher_test.ts
index 4545f84bf..98a2fa089 100644
--- a/packages/order-watcher/test/order_watcher_test.ts
+++ b/packages/order-watcher/test/order_watcher_test.ts
@@ -3,6 +3,7 @@ import { ContractWrappers } from '@0xproject/contract-wrappers';
import { tokenUtils } from '@0xproject/contract-wrappers/lib/test/utils/token_utils';
import { BlockchainLifecycle, callbackErrorReporter } from '@0xproject/dev-utils';
import { FillScenarios } from '@0xproject/fill-scenarios';
+import { getContractAddresses } from '@0xproject/migrations';
import { assetDataUtils, orderHashUtils } from '@0xproject/order-utils';
import {
DoneCallback,
@@ -36,13 +37,10 @@ const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('OrderWatcher', () => {
- const networkId = constants.TESTRPC_NETWORK_ID;
- const config = { networkId };
- const contractWrappers = new ContractWrappers(provider, config);
+ let contractWrappers: ContractWrappers;
let fillScenarios: FillScenarios;
let userAddresses: string[];
let zrxTokenAddress: string;
- let exchangeContractAddress: string;
let makerAssetData: string;
let takerAssetData: string;
let makerTokenAddress: string;
@@ -57,16 +55,22 @@ describe('OrderWatcher', () => {
const fillableAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(5), decimals);
before(async () => {
await blockchainLifecycle.startAsync();
+ const networkId = constants.TESTRPC_NETWORK_ID;
+ const contractAddresses = getContractAddresses();
+ const config = {
+ networkId,
+ contractAddresses,
+ };
+ contractWrappers = new ContractWrappers(provider, config);
userAddresses = await web3Wrapper.getAvailableAddressesAsync();
- zrxTokenAddress = tokenUtils.getProtocolTokenAddress();
- exchangeContractAddress = contractWrappers.exchange.getContractAddress();
+ zrxTokenAddress = contractAddresses.zrxToken;
fillScenarios = new FillScenarios(
provider,
userAddresses,
zrxTokenAddress,
- exchangeContractAddress,
- contractWrappers.erc20Proxy.getContractAddress(),
- contractWrappers.erc721Proxy.getContractAddress(),
+ contractAddresses.exchange,
+ contractAddresses.erc20Proxy,
+ contractAddresses.erc721Proxy,
);
[coinbase, makerAddress, takerAddress, feeRecipient] = userAddresses;
[makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses();
@@ -75,7 +79,7 @@ describe('OrderWatcher', () => {
assetDataUtils.encodeERC20AssetData(takerTokenAddress),
];
const orderWatcherConfig = {};
- orderWatcher = new OrderWatcher(provider, networkId, orderWatcherConfig);
+ orderWatcher = new OrderWatcher(provider, networkId, contractAddresses, orderWatcherConfig);
});
after(async () => {
await blockchainLifecycle.revertAsync();
diff --git a/packages/order-watcher/test/utils/token_utils.ts b/packages/order-watcher/test/utils/token_utils.ts
deleted file mode 100644
index f91b3797f..000000000
--- a/packages/order-watcher/test/utils/token_utils.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import { Token } from '@0xproject/types';
-import * as _ from 'lodash';
-
-import { InternalOrderWatcherError } from '../../src/types';
-
-const PROTOCOL_TOKEN_SYMBOL = 'ZRX';
-const WETH_TOKEN_SYMBOL = 'WETH';
-
-export class TokenUtils {
- private readonly _tokens: Token[];
- constructor(tokens: Token[]) {
- this._tokens = tokens;
- }
- public getProtocolTokenOrThrow(): Token {
- const zrxToken = _.find(this._tokens, { symbol: PROTOCOL_TOKEN_SYMBOL });
- if (_.isUndefined(zrxToken)) {
- throw new Error(InternalOrderWatcherError.ZrxNotInTokenRegistry);
- }
- return zrxToken;
- }
- public getWethTokenOrThrow(): Token {
- const wethToken = _.find(this._tokens, { symbol: WETH_TOKEN_SYMBOL });
- if (_.isUndefined(wethToken)) {
- throw new Error(InternalOrderWatcherError.WethNotInTokenRegistry);
- }
- return wethToken;
- }
- public getDummyTokens(): Token[] {
- const dummyTokens = _.filter(this._tokens, token => {
- return !_.includes([PROTOCOL_TOKEN_SYMBOL, WETH_TOKEN_SYMBOL], token.symbol);
- });
- return dummyTokens;
- }
-}