Use provider over web3 in deployer, dev-utils and subprovider tests, rename subprovider to ganacheSubprovider in test util

This commit is contained in:
Fabio Berger
2018-04-06 15:04:17 +09:00
parent 24454938e5
commit 75a51af006
9 changed files with 21 additions and 18 deletions

View File

@@ -41,8 +41,8 @@ async function onCompileCommandAsync(argv: CliOptions): Promise<void> {
*/
async function onDeployCommandAsync(argv: CliOptions): Promise<void> {
const url = argv.jsonrpcUrl;
const web3Provider = new Web3.providers.HttpProvider(url);
const web3Wrapper = new Web3Wrapper(web3Provider);
const provider = new Web3.providers.HttpProvider(url);
const web3Wrapper = new Web3Wrapper(provider);
const networkId = await web3Wrapper.getNetworkIdAsync();
const compilerOpts: CompilerOptions = {
contractsDir: argv.contractsDir,

View File

@@ -38,17 +38,17 @@ export class Deployer {
this._artifactsDir = opts.artifactsDir;
this._networkId = opts.networkId;
this._defaults = opts.defaults;
let web3Provider: Provider;
let provider: Provider;
if (_.isUndefined((opts as ProviderDeployerOptions).provider)) {
const jsonrpcUrl = (opts as UrlDeployerOptions).jsonrpcUrl;
if (_.isUndefined(jsonrpcUrl)) {
throw new Error(`Deployer options don't contain web3Provider nor jsonrpcUrl. Please pass one of them`);
throw new Error(`Deployer options don't contain provider nor jsonrpcUrl. Please pass one of them`);
}
web3Provider = new Web3.providers.HttpProvider(jsonrpcUrl);
provider = new Web3.providers.HttpProvider(jsonrpcUrl);
} else {
web3Provider = (opts as ProviderDeployerOptions).provider;
provider = (opts as ProviderDeployerOptions).provider;
}
this.web3Wrapper = new Web3Wrapper(web3Provider, this._defaults);
this.web3Wrapper = new Web3Wrapper(provider, this._defaults);
}
/**
* Loads a contract's corresponding artifacts and deploys it with the supplied constructor arguments.

View File

@@ -27,7 +27,7 @@ describe('#Deployer', () => {
const deployerOpts = {
artifactsDir,
networkId: constants.networkId,
web3Provider: provider,
provider,
defaults: {
gasPrice: constants.gasPrice,
},

View File

@@ -1,6 +1,9 @@
import { web3Factory } from '@0xproject/dev-utils';
import { Provider } from '@0xproject/types';
import * as Web3 from 'web3';
const web3ProviderConfig = { shouldUseInProcessGanache: true };
const web3Instance = web3Factory.create(web3ProviderConfig);
export const provider = web3Instance.currentProvider;
const providerConfigs = { shouldUseInProcessGanache: true };
const web3Instance = web3Factory.create(providerConfigs);
const provider: Provider = web3Instance.currentProvider;
export { provider };

View File

@@ -8,8 +8,8 @@ import { BlockchainLifecycle, web3Factory } from '../src';
const expect = chai.expect;
describe('BlockchainLifecycle tests', () => {
const web3Provider = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
const web3Wrapper = new Web3Wrapper(web3Provider);
const provider = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
const web3Wrapper = new Web3Wrapper(provider);
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('#startAsync/revertAsync', () => {
it('reverts changes in between', async () => {

View File

@@ -8,8 +8,8 @@ import { web3Factory } from '../src';
const expect = chai.expect;
describe('RPC tests', () => {
const web3Provider = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
const web3Wrapper = new Web3Wrapper(web3Provider);
const provider = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
const web3Wrapper = new Web3Wrapper(provider);
describe('#mineBlockAsync', () => {
it('increases block number when called', async () => {
const blockNumberBefore = await web3Wrapper.getBlockNumberAsync();

View File

@@ -8,8 +8,8 @@ import Web3ProviderEngine = require('web3-provider-engine');
import { LedgerSubprovider } from '../../src';
import { DoneCallback, LedgerCommunicationClient, LedgerSubproviderErrors } from '../../src/types';
import { chaiSetup } from '../chai_setup';
import { ganacheSubprovider } from '../utils/ganache_subprovider';
import { reportCallbackErrors } from '../utils/report_callback_errors';
import { subprovider as ganacheSubprovider } from '../utils/subprovider';
chaiSetup.configure();
const expect = chai.expect;

View File

@@ -8,8 +8,8 @@ import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
import { RedundantRPCSubprovider } from '../../src';
import { DoneCallback } from '../../src/types';
import { chaiSetup } from '../chai_setup';
import { ganacheSubprovider } from '../utils/ganache_subprovider';
import { reportCallbackErrors } from '../utils/report_callback_errors';
import { subprovider as ganacheSubprovider } from '../utils/subprovider';
const expect = chai.expect;
chaiSetup.configure();

View File

@@ -9,7 +9,7 @@ const logger = {
},
};
export const subprovider = new GanacheSubprovider({
export const ganacheSubprovider = new GanacheSubprovider({
logger,
verbose: false,
port: configs.port,