diff options
Diffstat (limited to 'packages/0x.js/test')
-rw-r--r-- | packages/0x.js/test/artifacts_test.ts | 9 | ||||
-rw-r--r-- | packages/0x.js/test/event_watcher_test.ts | 2 | ||||
-rw-r--r-- | packages/0x.js/test/exchange_wrapper_test.ts | 4 | ||||
-rw-r--r-- | packages/0x.js/test/utils/constants.ts | 2 | ||||
-rw-r--r-- | packages/0x.js/test/web3_wrapper_test.ts | 32 |
5 files changed, 11 insertions, 38 deletions
diff --git a/packages/0x.js/test/artifacts_test.ts b/packages/0x.js/test/artifacts_test.ts index 65feb306e..1c36fb358 100644 --- a/packages/0x.js/test/artifacts_test.ts +++ b/packages/0x.js/test/artifacts_test.ts @@ -12,15 +12,15 @@ const expect = chai.expect; const TIMEOUT = 10000; describe('Artifacts', () => { - const config = { - networkId: constants.TESTRPC_NETWORK_ID, - }; describe('contracts are deployed on kovan', () => { const kovanRpcUrl = constants.KOVAN_RPC_URL; const packageJSONContent = fs.readFileSync('package.json', 'utf-8'); const packageJSON = JSON.parse(packageJSONContent); const mnemonic = packageJSON.config.mnemonic; const web3Provider = new HDWalletProvider(mnemonic, kovanRpcUrl); + const config = { + networkId: constants.KOVAN_NETWORK_ID, + }; const zeroEx = new ZeroEx(web3Provider, config); it('token registry contract is deployed', async () => { await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync(); @@ -38,6 +38,9 @@ describe('Artifacts', () => { const packageJSON = JSON.parse(packageJSONContent); const mnemonic = packageJSON.config.mnemonic; const web3Provider = new HDWalletProvider(mnemonic, ropstenRpcUrl); + const config = { + networkId: constants.ROPSTEN_NETWORK_ID, + }; const zeroEx = new ZeroEx(web3Provider, config); it('token registry contract is deployed', async () => { await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync(); diff --git a/packages/0x.js/test/event_watcher_test.ts b/packages/0x.js/test/event_watcher_test.ts index 0b0d6d885..fc52d522a 100644 --- a/packages/0x.js/test/event_watcher_test.ts +++ b/packages/0x.js/test/event_watcher_test.ts @@ -58,7 +58,7 @@ describe('EventWatcher', () => { before(async () => { web3 = web3Factory.create(); const pollingIntervalMs = 10; - web3Wrapper = new Web3Wrapper(web3.currentProvider); + web3Wrapper = new Web3Wrapper(web3.currentProvider, constants.TESTRPC_NETWORK_ID); eventWatcher = new EventWatcher(web3Wrapper, pollingIntervalMs); }); afterEach(() => { diff --git a/packages/0x.js/test/exchange_wrapper_test.ts b/packages/0x.js/test/exchange_wrapper_test.ts index 773829b4e..5d1ff8f50 100644 --- a/packages/0x.js/test/exchange_wrapper_test.ts +++ b/packages/0x.js/test/exchange_wrapper_test.ts @@ -744,8 +744,8 @@ describe('ExchangeWrapper', () => { }); }); describe('#getZRXTokenAddressAsync', () => { - it('gets the same token as is in token registry', async () => { - const zrxAddress = await zeroEx.exchange.getZRXTokenAddressAsync(); + it('gets the same token as is in token registry', () => { + const zrxAddress = zeroEx.exchange.getZRXTokenAddress(); const zrxToken = tokenUtils.getProtocolTokenOrThrow(); expect(zrxAddress).to.equal(zrxToken.address); }); diff --git a/packages/0x.js/test/utils/constants.ts b/packages/0x.js/test/utils/constants.ts index 5992c226e..212abf4d6 100644 --- a/packages/0x.js/test/utils/constants.ts +++ b/packages/0x.js/test/utils/constants.ts @@ -2,6 +2,8 @@ export const constants = { NULL_ADDRESS: '0x0000000000000000000000000000000000000000', RPC_HOST: 'localhost', RPC_PORT: 8545, + ROPSTEN_NETWORK_ID: 3, + KOVAN_NETWORK_ID: 42, TESTRPC_NETWORK_ID: 50, KOVAN_RPC_URL: 'https://kovan.infura.io', ROPSTEN_RPC_URL: 'https://ropsten.infura.io', diff --git a/packages/0x.js/test/web3_wrapper_test.ts b/packages/0x.js/test/web3_wrapper_test.ts deleted file mode 100644 index ccbf336ab..000000000 --- a/packages/0x.js/test/web3_wrapper_test.ts +++ /dev/null @@ -1,32 +0,0 @@ -import * as chai from 'chai'; -import {web3Factory} from './utils/web3_factory'; -import {ZeroEx} from '../src/'; -import {Web3Wrapper} from '../src/web3_wrapper'; -import {constants} from './utils/constants'; - -chai.config.includeStack = true; -const expect = chai.expect; - -describe('Web3Wrapper', () => { - const web3Provider = web3Factory.create().currentProvider; - const config = { - networkId: constants.TESTRPC_NETWORK_ID, - }; - describe('#getNetworkIdIfExistsAsync', () => { - it('caches network id requests', async () => { - const web3Wrapper = (new ZeroEx(web3Provider, config) as any)._web3Wrapper as Web3Wrapper; - expect((web3Wrapper as any).networkIdIfExists).to.be.undefined(); - const networkIdIfExists = await web3Wrapper.getNetworkIdIfExistsAsync(); - expect((web3Wrapper as any).networkIdIfExists).to.be.equal(constants.TESTRPC_NETWORK_ID); - }); - it('invalidates network id cache on setProvider call', async () => { - const web3Wrapper = (new ZeroEx(web3Provider, config) as any)._web3Wrapper as Web3Wrapper; - expect((web3Wrapper as any).networkIdIfExists).to.be.undefined(); - const networkIdIfExists = await web3Wrapper.getNetworkIdIfExistsAsync(); - expect((web3Wrapper as any).networkIdIfExists).to.be.equal(constants.TESTRPC_NETWORK_ID); - const newProvider = web3Factory.create().currentProvider; - web3Wrapper.setProvider(newProvider); - expect((web3Wrapper as any).networkIdIfExists).to.be.undefined(); - }); - }); -}); |