Make an RPC constructor param implicit

This commit is contained in:
Leonid Logvinov
2018-01-30 14:03:54 +01:00
parent 6ebf8a57d1
commit 6205209fbb
23 changed files with 27 additions and 26 deletions

View File

@@ -11,7 +11,7 @@ import { chaiSetup } from './utils/chai_setup';
import { constants } from './utils/constants'; import { constants } from './utils/constants';
import { TokenUtils } from './utils/token_utils'; import { TokenUtils } from './utils/token_utils';
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;

View File

@@ -27,7 +27,7 @@ import { TokenUtils } from './utils/token_utils';
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
// Since the address depositing/withdrawing ETH/WETH also needs to pay gas costs for the transaction, // Since the address depositing/withdrawing ETH/WETH also needs to pay gas costs for the transaction,
// a small amount of ETH will be used to pay this gas cost. We therefore check that the difference between // a small amount of ETH will be used to pay this gas cost. We therefore check that the difference between

View File

@@ -11,7 +11,7 @@ import { constants } from './utils/constants';
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
describe('ExchangeTransferSimulator', () => { describe('ExchangeTransferSimulator', () => {
const web3 = web3Factory.create(); const web3 = web3Factory.create();

View File

@@ -28,7 +28,7 @@ import { TokenUtils } from './utils/token_utils';
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
const NON_EXISTENT_ORDER_HASH = '0x79370342234e7acd6bbeac335bd3bb1d368383294b64b8160a00f4060e4d3777'; const NON_EXISTENT_ORDER_HASH = '0x79370342234e7acd6bbeac335bd3bb1d368383294b64b8160a00f4060e4d3777';

View File

@@ -19,7 +19,7 @@ import { TokenUtils } from './utils/token_utils';
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
describe('ExpirationWatcher', () => { describe('ExpirationWatcher', () => {
let web3: Web3; let web3: Web3;

View File

@@ -27,7 +27,7 @@ const TIMEOUT_MS = 150;
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
describe('OrderStateWatcher', () => { describe('OrderStateWatcher', () => {
let web3: Web3; let web3: Web3;

View File

@@ -16,7 +16,7 @@ import { TokenUtils } from './utils/token_utils';
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
describe('OrderValidation', () => { describe('OrderValidation', () => {
let web3: Web3; let web3: Web3;

View File

@@ -13,7 +13,7 @@ import { constants } from './utils/constants';
import { assertNodeCallbackError } from './utils/report_callback_errors'; import { assertNodeCallbackError } from './utils/report_callback_errors';
chaiSetup.configure(); chaiSetup.configure();
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
describe('SubscriptionTest', () => { describe('SubscriptionTest', () => {
let web3: Web3; let web3: Web3;

View File

@@ -11,7 +11,7 @@ import { constants } from './utils/constants';
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
const TOKEN_REGISTRY_SIZE_AFTER_MIGRATION = 7; const TOKEN_REGISTRY_SIZE_AFTER_MIGRATION = 7;

View File

@@ -25,7 +25,7 @@ import { TokenUtils } from './utils/token_utils';
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
describe('TokenWrapper', () => { describe('TokenWrapper', () => {
let web3: Web3; let web3: Web3;

View File

@@ -14,7 +14,7 @@ chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
const web3 = web3Factory.create(); const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider); const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
describe('EtherToken', () => { describe('EtherToken', () => {
let account: string; let account: string;

View File

@@ -27,7 +27,7 @@ chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
const web3 = web3Factory.create(); const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider); const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
describe('Exchange', () => { describe('Exchange', () => {
let maker: string; let maker: string;

View File

@@ -18,7 +18,7 @@ const expect = chai.expect;
const web3 = web3Factory.create(); const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider); const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
describe('Exchange', () => { describe('Exchange', () => {
let maker: string; let maker: string;

View File

@@ -19,7 +19,7 @@ chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
const web3 = web3Factory.create(); const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider); const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
describe('Exchange', () => { describe('Exchange', () => {
let maker: string; let maker: string;

View File

@@ -1,5 +1,5 @@
import { LogWithDecodedArgs, ZeroEx } from '0x.js'; import { LogWithDecodedArgs, ZeroEx } from '0x.js';
import { BlockchainLifecycle, devConstants, RPC, web3Factory } from '@0xproject/dev-utils'; import { BlockchainLifecycle, RPC, web3Factory } from '@0xproject/dev-utils';
import { AbiDecoder, BigNumber } from '@0xproject/utils'; import { AbiDecoder, BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as chai from 'chai'; import * as chai from 'chai';
@@ -20,7 +20,7 @@ const expect = chai.expect;
const web3 = web3Factory.create(); const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider); const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
const zeroEx = new ZeroEx(web3.currentProvider, { networkId: constants.TESTRPC_NETWORK_ID }); const zeroEx = new ZeroEx(web3.currentProvider, { networkId: constants.TESTRPC_NETWORK_ID });
const abiDecoder = new AbiDecoder([MULTI_SIG_ABI]); const abiDecoder = new AbiDecoder([MULTI_SIG_ABI]);
@@ -40,7 +40,7 @@ describe('MultiSigWalletWithTimeLock', () => {
let rpc: RPC; let rpc: RPC;
before(async () => { before(async () => {
rpc = new RPC(devConstants.RPC_URL); rpc = new RPC();
}); });
beforeEach(async () => { beforeEach(async () => {
await blockchainLifecycle.startAsync(); await blockchainLifecycle.startAsync();

View File

@@ -22,7 +22,7 @@ chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
const web3 = web3Factory.create(); const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider); const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
const abiDecoder = new AbiDecoder([MUTISIG_WALLET_WITH_TIME_LOCK_EXCEPT_REMOVE_AUTHORIZED_ADDRESS_ABI]); const abiDecoder = new AbiDecoder([MUTISIG_WALLET_WITH_TIME_LOCK_EXCEPT_REMOVE_AUTHORIZED_ADDRESS_ABI]);
describe('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', () => { describe('MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress', () => {

View File

@@ -17,7 +17,7 @@ chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
const web3 = web3Factory.create(); const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider); const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
describe('TokenRegistry', () => { describe('TokenRegistry', () => {
let owner: string; let owner: string;

View File

@@ -12,7 +12,7 @@ chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
const web3 = web3Factory.create(); const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider); const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
describe('TokenTransferProxy', () => { describe('TokenTransferProxy', () => {
let owner: string; let owner: string;

View File

@@ -13,7 +13,7 @@ chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
const web3 = web3Factory.create(); const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider); const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
describe('TokenTransferProxy', () => { describe('TokenTransferProxy', () => {
let accounts: string[]; let accounts: string[];

View File

@@ -15,7 +15,7 @@ const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider); const web3Wrapper = new Web3Wrapper(web3.currentProvider);
chaiSetup.configure(); chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
describe('UnlimitedAllowanceToken', () => { describe('UnlimitedAllowanceToken', () => {
let owner: string; let owner: string;

View File

@@ -15,7 +15,7 @@ chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
const web3 = web3Factory.create(); const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider); const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
describe('UnlimitedAllowanceTokenV2', () => { describe('UnlimitedAllowanceTokenV2', () => {
const config = { const config = {

View File

@@ -15,7 +15,7 @@ chaiSetup.configure();
const expect = chai.expect; const expect = chai.expect;
const web3 = web3Factory.create(); const web3 = web3Factory.create();
const web3Wrapper = new Web3Wrapper(web3.currentProvider); const web3Wrapper = new Web3Wrapper(web3.currentProvider);
const blockchainLifecycle = new BlockchainLifecycle(devConstants.RPC_URL); const blockchainLifecycle = new BlockchainLifecycle();
describe('ZRXToken', () => { describe('ZRXToken', () => {
let owner: string; let owner: string;

View File

@@ -1,10 +1,11 @@
import { constants } from './constants';
import { RPC } from './rpc'; import { RPC } from './rpc';
export class BlockchainLifecycle { export class BlockchainLifecycle {
private _rpc: RPC; private _rpc: RPC;
private _snapshotIdsStack: number[]; private _snapshotIdsStack: number[];
constructor(url: string) { constructor() {
this._rpc = new RPC(url); this._rpc = new RPC(constants.RPC_URL);
this._snapshotIdsStack = []; this._snapshotIdsStack = [];
} }
// TODO: In order to run these tests on an actual node, we should check if we are running against // TODO: In order to run these tests on an actual node, we should check if we are running against