diff options
Diffstat (limited to 'packages/0x.js/test/token_wrapper_test.ts')
-rw-r--r-- | packages/0x.js/test/token_wrapper_test.ts | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/packages/0x.js/test/token_wrapper_test.ts b/packages/0x.js/test/token_wrapper_test.ts index 988532abd..63f17acf7 100644 --- a/packages/0x.js/test/token_wrapper_test.ts +++ b/packages/0x.js/test/token_wrapper_test.ts @@ -1,10 +1,9 @@ -import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils'; +import { BlockchainLifecycle, devConstants } from '@0xproject/dev-utils'; import { EmptyWalletSubprovider } from '@0xproject/subproviders'; +import { Provider } from '@0xproject/types'; import { BigNumber } from '@0xproject/utils'; -import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as chai from 'chai'; import 'mocha'; -import * as Web3 from 'web3'; import Web3ProviderEngine = require('web3-provider-engine'); import { @@ -24,7 +23,7 @@ import { chaiSetup } from './utils/chai_setup'; import { constants } from './utils/constants'; import { reportNodeCallbackErrors } from './utils/report_callback_errors'; import { TokenUtils } from './utils/token_utils'; -import { web3, web3Wrapper } from './utils/web3_wrapper'; +import { provider, web3Wrapper } from './utils/web3_wrapper'; chaiSetup.configure(); const expect = chai.expect; @@ -41,7 +40,7 @@ describe('TokenWrapper', () => { networkId: constants.TESTRPC_NETWORK_ID, }; before(async () => { - zeroEx = new ZeroEx(web3.currentProvider, config); + zeroEx = new ZeroEx(provider, config); userAddresses = await zeroEx.getAvailableAddressesAsync(); tokens = await zeroEx.tokenRegistry.getTokensAsync(); tokenUtils = new TokenUtils(tokens); @@ -166,7 +165,7 @@ describe('TokenWrapper', () => { }); }); describe('#getBalanceAsync', () => { - describe('With web3 provider with accounts', () => { + describe('With provider with accounts', () => { it('should return the balance for an existing ERC20 token', async () => { const token = tokens[0]; const ownerAddress = coinbase; @@ -189,15 +188,14 @@ describe('TokenWrapper', () => { return expect(balance).to.be.bignumber.equal(expectedBalance); }); }); - describe('With web3 provider without accounts', () => { + describe('With provider without accounts', () => { let zeroExWithoutAccounts: ZeroEx; before(async () => { const hasAddresses = false; - const emptyWalletProvider = addEmptyWalletSubprovider(web3.currentProvider); - const web3WithoutAccounts = new Web3(emptyWalletProvider); - zeroExWithoutAccounts = new ZeroEx(web3WithoutAccounts.currentProvider, config); + const emptyWalletProvider = addEmptyWalletSubprovider(provider); + zeroExWithoutAccounts = new ZeroEx(emptyWalletProvider, config); }); - it('should return balance even when called with Web3 provider instance without addresses', async () => { + it('should return balance even when called with provider instance without addresses', async () => { const token = tokens[0]; const ownerAddress = coinbase; const balance = await zeroExWithoutAccounts.token.getBalanceAsync(token.address, ownerAddress); @@ -280,7 +278,7 @@ describe('TokenWrapper', () => { }); }); describe('#getAllowanceAsync', () => { - describe('With web3 provider with accounts', () => { + describe('With provider with accounts', () => { it('should get the proxy allowance', async () => { const token = tokens[0]; const ownerAddress = coinbase; @@ -302,13 +300,12 @@ describe('TokenWrapper', () => { return expect(allowance).to.be.bignumber.equal(expectedAllowance); }); }); - describe('With web3 provider without accounts', () => { + describe('With provider without accounts', () => { let zeroExWithoutAccounts: ZeroEx; before(async () => { const hasAddresses = false; - const emptyWalletProvider = addEmptyWalletSubprovider(web3.currentProvider); - const web3WithoutAccounts = new Web3(emptyWalletProvider); - zeroExWithoutAccounts = new ZeroEx(web3WithoutAccounts.currentProvider, config); + const emptyWalletProvider = addEmptyWalletSubprovider(provider); + zeroExWithoutAccounts = new ZeroEx(emptyWalletProvider, config); }); it('should get the proxy allowance', async () => { const token = tokens[0]; @@ -428,7 +425,7 @@ describe('TokenWrapper', () => { ); zeroEx.token.subscribe(tokenAddress, TokenEvents.Transfer, indexFilterValues, callbackNeverToBeCalled); const callbackToBeCalled = reportNodeCallbackErrors(done)(); - const newProvider = web3.currentProvider; + const newProvider = provider; zeroEx.setProvider(newProvider, constants.TESTRPC_NETWORK_ID); zeroEx.token.subscribe(tokenAddress, TokenEvents.Transfer, indexFilterValues, callbackToBeCalled); await zeroEx.token.transferAsync(tokenAddress, coinbase, addressWithoutFunds, transferAmount); @@ -520,7 +517,7 @@ describe('TokenWrapper', () => { }); // tslint:disable:max-file-line-count -function addEmptyWalletSubprovider(provider: Web3.Provider): Web3.Provider { +function addEmptyWalletSubprovider(provider: Provider): Provider { const providerEngine = new Web3ProviderEngine(); providerEngine.addProvider(new EmptyWalletSubprovider()); const currentSubproviders = (provider as any)._providers; |