Adjust the tests
This commit is contained in:
parent
cbf35de4c1
commit
311d42626a
@ -16,10 +16,10 @@ const expect = chai.expect;
|
|||||||
|
|
||||||
describe('ZeroEx library', () => {
|
describe('ZeroEx library', () => {
|
||||||
const web3 = web3Factory.create();
|
const web3 = web3Factory.create();
|
||||||
const networkId = 50;
|
const config = {
|
||||||
const zeroEx = new ZeroEx(web3.currentProvider, {
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
networkId,
|
};
|
||||||
});
|
const zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||||
describe('#setProvider', () => {
|
describe('#setProvider', () => {
|
||||||
it('overrides provider in nested web3s and invalidates contractInstances', async () => {
|
it('overrides provider in nested web3s and invalidates contractInstances', async () => {
|
||||||
// Instantiate the contract instances with the current provider
|
// Instantiate the contract instances with the current provider
|
||||||
@ -235,29 +235,29 @@ describe('ZeroEx library', () => {
|
|||||||
});
|
});
|
||||||
describe('#config', () => {
|
describe('#config', () => {
|
||||||
it('allows to specify exchange contract address', async () => {
|
it('allows to specify exchange contract address', async () => {
|
||||||
const config = {
|
const zeroExConfig = {
|
||||||
exchangeContractAddress: ZeroEx.NULL_ADDRESS,
|
exchangeContractAddress: ZeroEx.NULL_ADDRESS,
|
||||||
networkId,
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
};
|
};
|
||||||
const zeroExWithWrongExchangeAddress = new ZeroEx(web3.currentProvider, config);
|
const zeroExWithWrongExchangeAddress = new ZeroEx(web3.currentProvider, zeroExConfig);
|
||||||
return expect(zeroExWithWrongExchangeAddress.exchange.getContractAddressAsync())
|
return expect(zeroExWithWrongExchangeAddress.exchange.getContractAddressAsync())
|
||||||
.to.be.rejectedWith(ZeroExError.ContractDoesNotExist);
|
.to.be.rejectedWith(ZeroExError.ContractDoesNotExist);
|
||||||
});
|
});
|
||||||
it('allows to specify ether token contract address', async () => {
|
it('allows to specify ether token contract address', async () => {
|
||||||
const config = {
|
const zeroExConfig = {
|
||||||
etherTokenContractAddress: ZeroEx.NULL_ADDRESS,
|
etherTokenContractAddress: ZeroEx.NULL_ADDRESS,
|
||||||
networkId,
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
};
|
};
|
||||||
const zeroExWithWrongEtherTokenAddress = new ZeroEx(web3.currentProvider, config);
|
const zeroExWithWrongEtherTokenAddress = new ZeroEx(web3.currentProvider, zeroExConfig);
|
||||||
return expect(zeroExWithWrongEtherTokenAddress.etherToken.getContractAddressAsync())
|
return expect(zeroExWithWrongEtherTokenAddress.etherToken.getContractAddressAsync())
|
||||||
.to.be.rejectedWith(ZeroExError.ContractDoesNotExist);
|
.to.be.rejectedWith(ZeroExError.ContractDoesNotExist);
|
||||||
});
|
});
|
||||||
it('allows to specify token registry token contract address', async () => {
|
it('allows to specify token registry token contract address', async () => {
|
||||||
const config = {
|
const zeroExConfig = {
|
||||||
tokenRegistryContractAddress: ZeroEx.NULL_ADDRESS,
|
tokenRegistryContractAddress: ZeroEx.NULL_ADDRESS,
|
||||||
networkId,
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
};
|
};
|
||||||
const zeroExWithWrongTokenRegistryAddress = new ZeroEx(web3.currentProvider, config);
|
const zeroExWithWrongTokenRegistryAddress = new ZeroEx(web3.currentProvider, zeroExConfig);
|
||||||
return expect(zeroExWithWrongTokenRegistryAddress.tokenRegistry.getContractAddressAsync())
|
return expect(zeroExWithWrongTokenRegistryAddress.tokenRegistry.getContractAddressAsync())
|
||||||
.to.be.rejectedWith(ZeroExError.ContractDoesNotExist);
|
.to.be.rejectedWith(ZeroExError.ContractDoesNotExist);
|
||||||
});
|
});
|
||||||
|
@ -12,13 +12,16 @@ const expect = chai.expect;
|
|||||||
const TIMEOUT = 10000;
|
const TIMEOUT = 10000;
|
||||||
|
|
||||||
describe('Artifacts', () => {
|
describe('Artifacts', () => {
|
||||||
|
const config = {
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
};
|
||||||
describe('contracts are deployed on kovan', () => {
|
describe('contracts are deployed on kovan', () => {
|
||||||
const kovanRpcUrl = constants.KOVAN_RPC_URL;
|
const kovanRpcUrl = constants.KOVAN_RPC_URL;
|
||||||
const packageJSONContent = fs.readFileSync('package.json', 'utf-8');
|
const packageJSONContent = fs.readFileSync('package.json', 'utf-8');
|
||||||
const packageJSON = JSON.parse(packageJSONContent);
|
const packageJSON = JSON.parse(packageJSONContent);
|
||||||
const mnemonic = packageJSON.config.mnemonic;
|
const mnemonic = packageJSON.config.mnemonic;
|
||||||
const web3Provider = new HDWalletProvider(mnemonic, kovanRpcUrl);
|
const web3Provider = new HDWalletProvider(mnemonic, kovanRpcUrl);
|
||||||
const zeroEx = new ZeroEx(web3Provider);
|
const zeroEx = new ZeroEx(web3Provider, config);
|
||||||
it('token registry contract is deployed', async () => {
|
it('token registry contract is deployed', async () => {
|
||||||
await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
|
await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
|
||||||
}).timeout(TIMEOUT);
|
}).timeout(TIMEOUT);
|
||||||
@ -35,7 +38,7 @@ describe('Artifacts', () => {
|
|||||||
const packageJSON = JSON.parse(packageJSONContent);
|
const packageJSON = JSON.parse(packageJSONContent);
|
||||||
const mnemonic = packageJSON.config.mnemonic;
|
const mnemonic = packageJSON.config.mnemonic;
|
||||||
const web3Provider = new HDWalletProvider(mnemonic, ropstenRpcUrl);
|
const web3Provider = new HDWalletProvider(mnemonic, ropstenRpcUrl);
|
||||||
const zeroEx = new ZeroEx(web3Provider);
|
const zeroEx = new ZeroEx(web3Provider, config);
|
||||||
it('token registry contract is deployed', async () => {
|
it('token registry contract is deployed', async () => {
|
||||||
await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
|
await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync();
|
||||||
}).timeout(TIMEOUT);
|
}).timeout(TIMEOUT);
|
||||||
|
@ -2,13 +2,17 @@ import * as chai from 'chai';
|
|||||||
import 'mocha';
|
import 'mocha';
|
||||||
import {ZeroEx} from '../src';
|
import {ZeroEx} from '../src';
|
||||||
import {assert} from '../src/utils/assert';
|
import {assert} from '../src/utils/assert';
|
||||||
|
import {constants} from './utils/constants';
|
||||||
import {web3Factory} from './utils/web3_factory';
|
import {web3Factory} from './utils/web3_factory';
|
||||||
|
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
|
|
||||||
describe('Assertion library', () => {
|
describe('Assertion library', () => {
|
||||||
const web3 = web3Factory.create();
|
const web3 = web3Factory.create();
|
||||||
const zeroEx = new ZeroEx(web3.currentProvider);
|
const config = {
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
};
|
||||||
|
const zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||||
describe('#isSenderAddressHexAsync', () => {
|
describe('#isSenderAddressHexAsync', () => {
|
||||||
it('throws when address is invalid', async () => {
|
it('throws when address is invalid', async () => {
|
||||||
const address = '0xdeadbeef';
|
const address = '0xdeadbeef';
|
||||||
|
@ -4,6 +4,7 @@ import {chaiSetup} from './utils/chai_setup';
|
|||||||
import * as Web3 from 'web3';
|
import * as Web3 from 'web3';
|
||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import {web3Factory} from './utils/web3_factory';
|
import {web3Factory} from './utils/web3_factory';
|
||||||
|
import {constants} from './utils/constants';
|
||||||
import {ZeroEx, ZeroExError} from '../src';
|
import {ZeroEx, ZeroExError} from '../src';
|
||||||
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
|
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
|
||||||
|
|
||||||
@ -28,6 +29,7 @@ describe('EtherTokenWrapper', () => {
|
|||||||
const gasPrice = new BigNumber(1);
|
const gasPrice = new BigNumber(1);
|
||||||
const zeroExConfig = {
|
const zeroExConfig = {
|
||||||
gasPrice,
|
gasPrice,
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
};
|
};
|
||||||
before(async () => {
|
before(async () => {
|
||||||
web3 = web3Factory.create();
|
web3 = web3Factory.create();
|
||||||
|
@ -5,6 +5,7 @@ import * as Sinon from 'sinon';
|
|||||||
import * as Web3 from 'web3';
|
import * as Web3 from 'web3';
|
||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import {chaiSetup} from './utils/chai_setup';
|
import {chaiSetup} from './utils/chai_setup';
|
||||||
|
import {constants} from './utils/constants';
|
||||||
import {web3Factory} from './utils/web3_factory';
|
import {web3Factory} from './utils/web3_factory';
|
||||||
import {Web3Wrapper} from '../src/web3_wrapper';
|
import {Web3Wrapper} from '../src/web3_wrapper';
|
||||||
import {EventWatcher} from '../src/order_watcher/event_watcher';
|
import {EventWatcher} from '../src/order_watcher/event_watcher';
|
||||||
|
@ -2,6 +2,7 @@ import * as chai from 'chai';
|
|||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import {chaiSetup} from './utils/chai_setup';
|
import {chaiSetup} from './utils/chai_setup';
|
||||||
import {web3Factory} from './utils/web3_factory';
|
import {web3Factory} from './utils/web3_factory';
|
||||||
|
import {constants} from './utils/constants';
|
||||||
import {ZeroEx, ExchangeContractErrs, Token} from '../src';
|
import {ZeroEx, ExchangeContractErrs, Token} from '../src';
|
||||||
import {TradeSide, TransferType} from '../src/types';
|
import {TradeSide, TransferType} from '../src/types';
|
||||||
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
|
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
|
||||||
@ -13,7 +14,10 @@ const blockchainLifecycle = new BlockchainLifecycle();
|
|||||||
|
|
||||||
describe('ExchangeTransferSimulator', () => {
|
describe('ExchangeTransferSimulator', () => {
|
||||||
const web3 = web3Factory.create();
|
const web3 = web3Factory.create();
|
||||||
const zeroEx = new ZeroEx(web3.currentProvider);
|
const config = {
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
};
|
||||||
|
const zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||||
const transferAmount = new BigNumber(5);
|
const transferAmount = new BigNumber(5);
|
||||||
let userAddresses: string[];
|
let userAddresses: string[];
|
||||||
let tokens: Token[];
|
let tokens: Token[];
|
||||||
|
@ -22,6 +22,7 @@ import {
|
|||||||
import {DoneCallback, BlockParamLiteral} from '../src/types';
|
import {DoneCallback, BlockParamLiteral} from '../src/types';
|
||||||
import {FillScenarios} from './utils/fill_scenarios';
|
import {FillScenarios} from './utils/fill_scenarios';
|
||||||
import {TokenUtils} from './utils/token_utils';
|
import {TokenUtils} from './utils/token_utils';
|
||||||
|
import {constants} from './utils/constants';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
@ -38,9 +39,12 @@ describe('ExchangeWrapper', () => {
|
|||||||
let zrxTokenAddress: string;
|
let zrxTokenAddress: string;
|
||||||
let fillScenarios: FillScenarios;
|
let fillScenarios: FillScenarios;
|
||||||
let exchangeContractAddress: string;
|
let exchangeContractAddress: string;
|
||||||
|
const config = {
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
};
|
||||||
before(async () => {
|
before(async () => {
|
||||||
web3 = web3Factory.create();
|
web3 = web3Factory.create();
|
||||||
zeroEx = new ZeroEx(web3.currentProvider);
|
zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||||
exchangeContractAddress = await zeroEx.exchange.getContractAddressAsync();
|
exchangeContractAddress = await zeroEx.exchange.getContractAddressAsync();
|
||||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||||
|
@ -20,12 +20,12 @@ import {
|
|||||||
OrderStateInvalid,
|
OrderStateInvalid,
|
||||||
ExchangeContractErrs,
|
ExchangeContractErrs,
|
||||||
} from '../src';
|
} from '../src';
|
||||||
|
import {constants} from './utils/constants';
|
||||||
import {TokenUtils} from './utils/token_utils';
|
import {TokenUtils} from './utils/token_utils';
|
||||||
import {FillScenarios} from './utils/fill_scenarios';
|
import {FillScenarios} from './utils/fill_scenarios';
|
||||||
import {DoneCallback} from '../src/types';
|
import {DoneCallback} from '../src/types';
|
||||||
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
|
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
|
||||||
import {reportCallbackErrors} from './utils/report_callback_errors';
|
import {reportCallbackErrors} from './utils/report_callback_errors';
|
||||||
import {constants as constants} from './utils/constants';
|
|
||||||
|
|
||||||
const TIMEOUT_MS = 150;
|
const TIMEOUT_MS = 150;
|
||||||
|
|
||||||
@ -48,11 +48,14 @@ describe('OrderStateWatcher', () => {
|
|||||||
let taker: string;
|
let taker: string;
|
||||||
let web3Wrapper: Web3Wrapper;
|
let web3Wrapper: Web3Wrapper;
|
||||||
let signedOrder: SignedOrder;
|
let signedOrder: SignedOrder;
|
||||||
|
const config = {
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
};
|
||||||
const decimals = constants.ZRX_DECIMALS;
|
const decimals = constants.ZRX_DECIMALS;
|
||||||
const fillableAmount = ZeroEx.toBaseUnitAmount(new BigNumber(5), decimals);
|
const fillableAmount = ZeroEx.toBaseUnitAmount(new BigNumber(5), decimals);
|
||||||
before(async () => {
|
before(async () => {
|
||||||
web3 = web3Factory.create();
|
web3 = web3Factory.create();
|
||||||
zeroEx = new ZeroEx(web3.currentProvider);
|
zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||||
exchangeContractAddress = await zeroEx.exchange.getContractAddressAsync();
|
exchangeContractAddress = await zeroEx.exchange.getContractAddressAsync();
|
||||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||||
[, maker, taker] = userAddresses;
|
[, maker, taker] = userAddresses;
|
||||||
|
@ -7,6 +7,7 @@ import {web3Factory} from './utils/web3_factory';
|
|||||||
import {ZeroEx, SignedOrder, Token, ExchangeContractErrs, ZeroExError} from '../src';
|
import {ZeroEx, SignedOrder, Token, ExchangeContractErrs, ZeroExError} from '../src';
|
||||||
import {TradeSide, TransferType} from '../src/types';
|
import {TradeSide, TransferType} from '../src/types';
|
||||||
import {TokenUtils} from './utils/token_utils';
|
import {TokenUtils} from './utils/token_utils';
|
||||||
|
import {constants} from './utils/constants';
|
||||||
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
|
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
|
||||||
import {FillScenarios} from './utils/fill_scenarios';
|
import {FillScenarios} from './utils/fill_scenarios';
|
||||||
import {OrderValidationUtils} from '../src/utils/order_validation_utils';
|
import {OrderValidationUtils} from '../src/utils/order_validation_utils';
|
||||||
@ -34,9 +35,12 @@ describe('OrderValidation', () => {
|
|||||||
let orderValidationUtils: OrderValidationUtils;
|
let orderValidationUtils: OrderValidationUtils;
|
||||||
const fillableAmount = new BigNumber(5);
|
const fillableAmount = new BigNumber(5);
|
||||||
const fillTakerAmount = new BigNumber(5);
|
const fillTakerAmount = new BigNumber(5);
|
||||||
|
const config = {
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
};
|
||||||
before(async () => {
|
before(async () => {
|
||||||
web3 = web3Factory.create();
|
web3 = web3Factory.create();
|
||||||
zeroEx = new ZeroEx(web3.currentProvider);
|
zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||||
exchangeContractAddress = await zeroEx.exchange.getContractAddressAsync();
|
exchangeContractAddress = await zeroEx.exchange.getContractAddressAsync();
|
||||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||||
[coinbase, makerAddress, takerAddress, feeRecipient] = userAddresses;
|
[coinbase, makerAddress, takerAddress, feeRecipient] = userAddresses;
|
||||||
|
@ -7,6 +7,7 @@ import * as Web3 from 'web3';
|
|||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import promisify = require('es6-promisify');
|
import promisify = require('es6-promisify');
|
||||||
import {web3Factory} from './utils/web3_factory';
|
import {web3Factory} from './utils/web3_factory';
|
||||||
|
import {constants} from './utils/constants';
|
||||||
import {
|
import {
|
||||||
ZeroEx,
|
ZeroEx,
|
||||||
ZeroExError,
|
ZeroExError,
|
||||||
@ -31,9 +32,12 @@ describe('SubscriptionTest', () => {
|
|||||||
let tokenUtils: TokenUtils;
|
let tokenUtils: TokenUtils;
|
||||||
let coinbase: string;
|
let coinbase: string;
|
||||||
let addressWithoutFunds: string;
|
let addressWithoutFunds: string;
|
||||||
|
const config = {
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
};
|
||||||
before(async () => {
|
before(async () => {
|
||||||
web3 = web3Factory.create();
|
web3 = web3Factory.create();
|
||||||
zeroEx = new ZeroEx(web3.currentProvider);
|
zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||||
tokenUtils = new TokenUtils(tokens);
|
tokenUtils = new TokenUtils(tokens);
|
||||||
|
@ -2,6 +2,7 @@ import * as _ from 'lodash';
|
|||||||
import 'mocha';
|
import 'mocha';
|
||||||
import * as chai from 'chai';
|
import * as chai from 'chai';
|
||||||
import {SchemaValidator, schemas} from '@0xproject/json-schemas';
|
import {SchemaValidator, schemas} from '@0xproject/json-schemas';
|
||||||
|
import {constants} from './utils/constants';
|
||||||
import {chaiSetup} from './utils/chai_setup';
|
import {chaiSetup} from './utils/chai_setup';
|
||||||
import {web3Factory} from './utils/web3_factory';
|
import {web3Factory} from './utils/web3_factory';
|
||||||
import {ZeroEx, Token} from '../src';
|
import {ZeroEx, Token} from '../src';
|
||||||
@ -24,9 +25,12 @@ describe('TokenRegistryWrapper', () => {
|
|||||||
const registeredName = '0x Protocol Token';
|
const registeredName = '0x Protocol Token';
|
||||||
const unregisteredSymbol = 'MAL';
|
const unregisteredSymbol = 'MAL';
|
||||||
const unregisteredName = 'Malicious Token';
|
const unregisteredName = 'Malicious Token';
|
||||||
|
const config = {
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
};
|
||||||
before(async () => {
|
before(async () => {
|
||||||
const web3 = web3Factory.create();
|
const web3 = web3Factory.create();
|
||||||
zeroEx = new ZeroEx(web3.currentProvider);
|
zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||||
_.map(tokens, token => {
|
_.map(tokens, token => {
|
||||||
tokenAddressBySymbol[token.symbol] = token.address;
|
tokenAddressBySymbol[token.symbol] = token.address;
|
||||||
|
@ -2,6 +2,7 @@ import * as chai from 'chai';
|
|||||||
import {chaiSetup} from './utils/chai_setup';
|
import {chaiSetup} from './utils/chai_setup';
|
||||||
import {web3Factory} from './utils/web3_factory';
|
import {web3Factory} from './utils/web3_factory';
|
||||||
import {ZeroEx} from '../src';
|
import {ZeroEx} from '../src';
|
||||||
|
import {constants} from './utils/constants';
|
||||||
import {TokenTransferProxyWrapper} from '../src/contract_wrappers/token_transfer_proxy_wrapper';
|
import {TokenTransferProxyWrapper} from '../src/contract_wrappers/token_transfer_proxy_wrapper';
|
||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
@ -9,9 +10,12 @@ const expect = chai.expect;
|
|||||||
|
|
||||||
describe('TokenTransferProxyWrapper', () => {
|
describe('TokenTransferProxyWrapper', () => {
|
||||||
let zeroEx: ZeroEx;
|
let zeroEx: ZeroEx;
|
||||||
|
const config = {
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
};
|
||||||
before(async () => {
|
before(async () => {
|
||||||
const web3 = web3Factory.create();
|
const web3 = web3Factory.create();
|
||||||
zeroEx = new ZeroEx(web3.currentProvider);
|
zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||||
});
|
});
|
||||||
describe('#isAuthorizedAsync', () => {
|
describe('#isAuthorizedAsync', () => {
|
||||||
it('should return false if the address is not authorized', async () => {
|
it('should return false if the address is not authorized', async () => {
|
||||||
|
@ -19,6 +19,7 @@ import {
|
|||||||
LogEvent,
|
LogEvent,
|
||||||
DecodedLogEvent,
|
DecodedLogEvent,
|
||||||
} from '../src';
|
} from '../src';
|
||||||
|
import {constants} from './utils/constants';
|
||||||
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
|
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
|
||||||
import {TokenUtils} from './utils/token_utils';
|
import {TokenUtils} from './utils/token_utils';
|
||||||
import {DoneCallback, BlockParamLiteral} from '../src/types';
|
import {DoneCallback, BlockParamLiteral} from '../src/types';
|
||||||
@ -35,9 +36,12 @@ describe('TokenWrapper', () => {
|
|||||||
let tokenUtils: TokenUtils;
|
let tokenUtils: TokenUtils;
|
||||||
let coinbase: string;
|
let coinbase: string;
|
||||||
let addressWithoutFunds: string;
|
let addressWithoutFunds: string;
|
||||||
|
const config = {
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
};
|
||||||
before(async () => {
|
before(async () => {
|
||||||
web3 = web3Factory.create();
|
web3 = web3Factory.create();
|
||||||
zeroEx = new ZeroEx(web3.currentProvider);
|
zeroEx = new ZeroEx(web3.currentProvider, config);
|
||||||
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
userAddresses = await zeroEx.getAvailableAddressesAsync();
|
||||||
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
tokens = await zeroEx.tokenRegistry.getTokensAsync();
|
||||||
tokenUtils = new TokenUtils(tokens);
|
tokenUtils = new TokenUtils(tokens);
|
||||||
@ -184,7 +188,7 @@ describe('TokenWrapper', () => {
|
|||||||
before(async () => {
|
before(async () => {
|
||||||
const hasAddresses = false;
|
const hasAddresses = false;
|
||||||
const web3WithoutAccounts = web3Factory.create(hasAddresses);
|
const web3WithoutAccounts = web3Factory.create(hasAddresses);
|
||||||
zeroExWithoutAccounts = new ZeroEx(web3WithoutAccounts.currentProvider);
|
zeroExWithoutAccounts = new ZeroEx(web3WithoutAccounts.currentProvider, config);
|
||||||
});
|
});
|
||||||
it('should return balance even when called with Web3 provider instance without addresses', async () => {
|
it('should return balance even when called with Web3 provider instance without addresses', async () => {
|
||||||
const token = tokens[0];
|
const token = tokens[0];
|
||||||
@ -281,7 +285,7 @@ describe('TokenWrapper', () => {
|
|||||||
before(async () => {
|
before(async () => {
|
||||||
const hasAddresses = false;
|
const hasAddresses = false;
|
||||||
const web3WithoutAccounts = web3Factory.create(hasAddresses);
|
const web3WithoutAccounts = web3Factory.create(hasAddresses);
|
||||||
zeroExWithoutAccounts = new ZeroEx(web3WithoutAccounts.currentProvider);
|
zeroExWithoutAccounts = new ZeroEx(web3WithoutAccounts.currentProvider, config);
|
||||||
});
|
});
|
||||||
it('should get the proxy allowance', async () => {
|
it('should get the proxy allowance', async () => {
|
||||||
const token = tokens[0];
|
const token = tokens[0];
|
||||||
|
@ -9,15 +9,18 @@ const expect = chai.expect;
|
|||||||
|
|
||||||
describe('Web3Wrapper', () => {
|
describe('Web3Wrapper', () => {
|
||||||
const web3Provider = web3Factory.create().currentProvider;
|
const web3Provider = web3Factory.create().currentProvider;
|
||||||
|
const config = {
|
||||||
|
networkId: constants.TESTRPC_NETWORK_ID,
|
||||||
|
};
|
||||||
describe('#getNetworkIdIfExistsAsync', () => {
|
describe('#getNetworkIdIfExistsAsync', () => {
|
||||||
it('caches network id requests', async () => {
|
it('caches network id requests', async () => {
|
||||||
const web3Wrapper = (new ZeroEx(web3Provider) as any)._web3Wrapper as Web3Wrapper;
|
const web3Wrapper = (new ZeroEx(web3Provider, config) as any)._web3Wrapper as Web3Wrapper;
|
||||||
expect((web3Wrapper as any).networkIdIfExists).to.be.undefined();
|
expect((web3Wrapper as any).networkIdIfExists).to.be.undefined();
|
||||||
const networkIdIfExists = await web3Wrapper.getNetworkIdIfExistsAsync();
|
const networkIdIfExists = await web3Wrapper.getNetworkIdIfExistsAsync();
|
||||||
expect((web3Wrapper as any).networkIdIfExists).to.be.equal(constants.TESTRPC_NETWORK_ID);
|
expect((web3Wrapper as any).networkIdIfExists).to.be.equal(constants.TESTRPC_NETWORK_ID);
|
||||||
});
|
});
|
||||||
it('invalidates network id cache on setProvider call', async () => {
|
it('invalidates network id cache on setProvider call', async () => {
|
||||||
const web3Wrapper = (new ZeroEx(web3Provider) as any)._web3Wrapper as Web3Wrapper;
|
const web3Wrapper = (new ZeroEx(web3Provider, config) as any)._web3Wrapper as Web3Wrapper;
|
||||||
expect((web3Wrapper as any).networkIdIfExists).to.be.undefined();
|
expect((web3Wrapper as any).networkIdIfExists).to.be.undefined();
|
||||||
const networkIdIfExists = await web3Wrapper.getNetworkIdIfExistsAsync();
|
const networkIdIfExists = await web3Wrapper.getNetworkIdIfExistsAsync();
|
||||||
expect((web3Wrapper as any).networkIdIfExists).to.be.equal(constants.TESTRPC_NETWORK_ID);
|
expect((web3Wrapper as any).networkIdIfExists).to.be.equal(constants.TESTRPC_NETWORK_ID);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user