aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/test/0x.js_test.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-04-04 15:31:57 +0800
committerFabio Berger <me@fabioberger.com>2018-04-04 15:31:57 +0800
commit43e07e7ce3dd61af8048c20aa2355010f0c72c22 (patch)
tree84da5a773b83e1c5c452ccbd8fb22342f9d28c84 /packages/0x.js/test/0x.js_test.ts
parent5e4e27fed5b9b7c889e6e6e1805377b9eff31a3a (diff)
downloaddexon-sol-tools-43e07e7ce3dd61af8048c20aa2355010f0c72c22.tar
dexon-sol-tools-43e07e7ce3dd61af8048c20aa2355010f0c72c22.tar.gz
dexon-sol-tools-43e07e7ce3dd61af8048c20aa2355010f0c72c22.tar.bz2
dexon-sol-tools-43e07e7ce3dd61af8048c20aa2355010f0c72c22.tar.lz
dexon-sol-tools-43e07e7ce3dd61af8048c20aa2355010f0c72c22.tar.xz
dexon-sol-tools-43e07e7ce3dd61af8048c20aa2355010f0c72c22.tar.zst
dexon-sol-tools-43e07e7ce3dd61af8048c20aa2355010f0c72c22.zip
Update 0x.js to run tests against in-process ganache
Diffstat (limited to 'packages/0x.js/test/0x.js_test.ts')
-rw-r--r--packages/0x.js/test/0x.js_test.ts28
1 files changed, 23 insertions, 5 deletions
diff --git a/packages/0x.js/test/0x.js_test.ts b/packages/0x.js/test/0x.js_test.ts
index 70e85aa52..2ae944a99 100644
--- a/packages/0x.js/test/0x.js_test.ts
+++ b/packages/0x.js/test/0x.js_test.ts
@@ -1,17 +1,31 @@
+import { Deployer } from '@0xproject/deployer';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
import 'mocha';
+import * as path from 'path';
import * as Sinon from 'sinon';
import { ApprovalContractEventArgs, LogWithDecodedArgs, Order, TokenEvents, ZeroEx } from '../src';
+import { runMigrationsAsync } from './migrations/migrate';
import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
import { TokenUtils } from './utils/token_utils';
import { web3, web3Wrapper } from './utils/web3_wrapper';
+const artifactsDir = path.resolve('test', 'artifacts');
+const deployerOpts = {
+ artifactsDir,
+ web3Provider: web3.currentProvider,
+ networkId: constants.TESTRPC_NETWORK_ID,
+ defaults: {
+ gas: devConstants.GAS_ESTIMATE,
+ },
+};
+const deployer = new Deployer(deployerOpts);
+
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
chaiSetup.configure();
const expect = chai.expect;
@@ -19,10 +33,14 @@ const expect = chai.expect;
const SHOULD_ADD_PERSONAL_MESSAGE_PREFIX = false;
describe('ZeroEx library', () => {
- const config = {
- networkId: constants.TESTRPC_NETWORK_ID,
- };
- const zeroEx = new ZeroEx(web3.currentProvider, config);
+ let zeroEx: ZeroEx;
+ before(async () => {
+ await runMigrationsAsync(deployer);
+ const config = {
+ networkId: constants.TESTRPC_NETWORK_ID,
+ };
+ zeroEx = new ZeroEx(web3.currentProvider, config);
+ });
describe('#setProvider', () => {
it('overrides provider in nested web3s and invalidates contractInstances', async () => {
// Instantiate the contract instances with the current provider
@@ -31,7 +49,7 @@ describe('ZeroEx library', () => {
expect((zeroEx.exchange as any)._exchangeContractIfExists).to.not.be.undefined();
expect((zeroEx.tokenRegistry as any)._tokenRegistryContractIfExists).to.not.be.undefined();
- const newProvider = web3Factory.getRpcProvider();
+ const newProvider = web3.currentProvider;
// Add property to newProvider so that we can differentiate it from old provider
(newProvider as any).zeroExTestId = 1;
zeroEx.setProvider(newProvider, constants.TESTRPC_NETWORK_ID);