aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js/test/0x.js_test.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-04-12 07:56:13 +0800
committerFabio Berger <me@fabioberger.com>2018-04-12 07:56:13 +0800
commitfaedd2fa0b2582ea24ca4624e13ea7466de18408 (patch)
treeb5e02ec65e8ae5298761f07eae18df145024bb16 /packages/0x.js/test/0x.js_test.ts
parent41bd0e30d6d0a18530e31133efe57d35e3360ebd (diff)
parentc47fb8f9a83d409c092dd7449054fa16cf0fa1c9 (diff)
downloaddexon-sol-tools-faedd2fa0b2582ea24ca4624e13ea7466de18408.tar
dexon-sol-tools-faedd2fa0b2582ea24ca4624e13ea7466de18408.tar.gz
dexon-sol-tools-faedd2fa0b2582ea24ca4624e13ea7466de18408.tar.bz2
dexon-sol-tools-faedd2fa0b2582ea24ca4624e13ea7466de18408.tar.lz
dexon-sol-tools-faedd2fa0b2582ea24ca4624e13ea7466de18408.tar.xz
dexon-sol-tools-faedd2fa0b2582ea24ca4624e13ea7466de18408.tar.zst
dexon-sol-tools-faedd2fa0b2582ea24ca4624e13ea7466de18408.zip
Merge branch 'development' into fix/docImprovements
* development: (31 commits) Prettier ignore Metacoin artifacts Publish Updated CHANGELOGS Improve deployer error message Fix 0x.js tests Fix lint issue Simply export Move NULL_BYTES to @0xproject/utils Simplify the tests Fix lint error Add step to publishing that upload staging doc jsons, deploys staging website, opens every docs page and asks the dev to confirm that each one renders properly before publishing Fix web3Wrapper build command Add top-level `yarn lerna:stage_docs` to upload docJsons to the staging S3 bucket for all packages with a docs page Refactor publish script to have it's main execution body be lean and discrete steps Removed unused command Remove 0x.js test artifacts Fix tslint Move migrations into separate monorepo subpackage and hook it up to 0x.js and contracts Remove unused var Refactor RedundantRpcSubprovider into RedundantSubprovider ... # Conflicts: # packages/react-docs/CHANGELOG.json
Diffstat (limited to 'packages/0x.js/test/0x.js_test.ts')
-rw-r--r--packages/0x.js/test/0x.js_test.ts30
1 files changed, 20 insertions, 10 deletions
diff --git a/packages/0x.js/test/0x.js_test.ts b/packages/0x.js/test/0x.js_test.ts
index 70e85aa52..de5a6be58 100644
--- a/packages/0x.js/test/0x.js_test.ts
+++ b/packages/0x.js/test/0x.js_test.ts
@@ -1,16 +1,23 @@
+import { Deployer } from '@0xproject/deployer';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
+// HACK: This dependency is optional since it is only available when run from within
+// the monorepo. tslint doesn't handle optional dependencies
+// tslint:disable-next-line:no-implicit-dependencies
+import { runMigrationsAsync } from '@0xproject/migrations';
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 { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants';
+import { deployer } from './utils/deployer';
import { TokenUtils } from './utils/token_utils';
-import { web3, web3Wrapper } from './utils/web3_wrapper';
+import { provider, web3Wrapper } from './utils/web3_wrapper';
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
chaiSetup.configure();
@@ -19,10 +26,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(provider, config);
+ });
describe('#setProvider', () => {
it('overrides provider in nested web3s and invalidates contractInstances', async () => {
// Instantiate the contract instances with the current provider
@@ -31,10 +42,9 @@ 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();
// 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);
+ (provider as any).zeroExTestId = 1;
+ zeroEx.setProvider(provider, constants.TESTRPC_NETWORK_ID);
// Check that contractInstances with old provider are removed after provider update
expect((zeroEx.exchange as any)._exchangeContractIfExists).to.be.undefined();
@@ -278,7 +288,7 @@ describe('ZeroEx library', () => {
exchangeContractAddress: ZeroEx.NULL_ADDRESS,
networkId: constants.TESTRPC_NETWORK_ID,
};
- const zeroExWithWrongExchangeAddress = new ZeroEx(web3.currentProvider, zeroExConfig);
+ const zeroExWithWrongExchangeAddress = new ZeroEx(provider, zeroExConfig);
expect(zeroExWithWrongExchangeAddress.exchange.getContractAddress()).to.be.equal(ZeroEx.NULL_ADDRESS);
});
it('allows to specify token registry token contract address', async () => {
@@ -286,7 +296,7 @@ describe('ZeroEx library', () => {
tokenRegistryContractAddress: ZeroEx.NULL_ADDRESS,
networkId: constants.TESTRPC_NETWORK_ID,
};
- const zeroExWithWrongTokenRegistryAddress = new ZeroEx(web3.currentProvider, zeroExConfig);
+ const zeroExWithWrongTokenRegistryAddress = new ZeroEx(provider, zeroExConfig);
expect(zeroExWithWrongTokenRegistryAddress.tokenRegistry.getContractAddress()).to.be.equal(
ZeroEx.NULL_ADDRESS,
);