Update dev-utils and subproviders tests to use ganache in-process provider
This commit is contained in:
parent
6c02722f56
commit
5e4e27fed5
22
README.md
22
README.md
@ -74,7 +74,7 @@ You can include those by prepending @0xproject/typescript-typings package to you
|
||||
|
||||
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
|
||||
|
||||
Please read our [contribution guidelines](./CONTRIBUTING.md) before getting started.
|
||||
#### Read our [contribution guidelines](./CONTRIBUTING.md).
|
||||
|
||||
### Install dependencies
|
||||
|
||||
@ -118,24 +118,6 @@ yarn lerna:run lint
|
||||
|
||||
### Run Tests
|
||||
|
||||
Before running the tests, you will need to spin up a [TestRPC](https://www.npmjs.com/package/ethereumjs-testrpc) instance and deploy all the 0x smart contracts.
|
||||
|
||||
In a separate terminal, start TestRPC (a convenience command is provided as part of this repo)
|
||||
|
||||
```bash
|
||||
yarn testrpc
|
||||
```
|
||||
|
||||
Then in your main terminal run
|
||||
|
||||
```
|
||||
cd packages/contracts
|
||||
yarn migrate
|
||||
cd ..
|
||||
```
|
||||
|
||||
And finally from the root project directory run
|
||||
|
||||
```bash
|
||||
yarn lerna:run test
|
||||
yarn lerna:test
|
||||
```
|
||||
|
@ -8,7 +8,7 @@ import { BlockchainLifecycle, web3Factory } from '../src';
|
||||
const expect = chai.expect;
|
||||
|
||||
describe('BlockchainLifecycle tests', () => {
|
||||
const web3Provider = web3Factory.getRpcProvider();
|
||||
const web3Provider = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
|
||||
const web3Wrapper = new Web3Wrapper(web3Provider);
|
||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
describe('#startAsync/revertAsync', () => {
|
||||
|
@ -8,7 +8,7 @@ import { web3Factory } from '../src';
|
||||
const expect = chai.expect;
|
||||
|
||||
describe('RPC tests', () => {
|
||||
const web3Provider = web3Factory.getRpcProvider();
|
||||
const web3Provider = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
|
||||
const web3Wrapper = new Web3Wrapper(web3Provider);
|
||||
describe('#mineBlockAsync', () => {
|
||||
it('increases block number when called', async () => {
|
||||
|
@ -4,12 +4,12 @@ import * as ethUtils from 'ethereumjs-util';
|
||||
import * as _ from 'lodash';
|
||||
import Web3 = require('web3');
|
||||
import Web3ProviderEngine = require('web3-provider-engine');
|
||||
import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
|
||||
|
||||
import { LedgerSubprovider } from '../../src';
|
||||
import { DoneCallback, LedgerCommunicationClient, LedgerSubproviderErrors } from '../../src/types';
|
||||
import { chaiSetup } from '../chai_setup';
|
||||
import { reportCallbackErrors } from '../utils/report_callback_errors';
|
||||
import { subprovider as ganacheSubprovider } from '../utils/subprovider';
|
||||
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
@ -99,10 +99,7 @@ describe('LedgerSubprovider', () => {
|
||||
before(() => {
|
||||
provider = new Web3ProviderEngine();
|
||||
provider.addProvider(ledgerSubprovider);
|
||||
const httpProvider = new RpcSubprovider({
|
||||
rpcUrl: 'http://localhost:8545',
|
||||
});
|
||||
provider.addProvider(httpProvider);
|
||||
provider.addProvider(ganacheSubprovider);
|
||||
provider.start();
|
||||
});
|
||||
describe('success cases', () => {
|
||||
|
@ -3,11 +3,13 @@ import * as chai from 'chai';
|
||||
import * as _ from 'lodash';
|
||||
import Web3 = require('web3');
|
||||
import Web3ProviderEngine = require('web3-provider-engine');
|
||||
import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
|
||||
|
||||
import { RedundantRPCSubprovider } from '../../src';
|
||||
import { DoneCallback } from '../../src/types';
|
||||
import { chaiSetup } from '../chai_setup';
|
||||
import { reportCallbackErrors } from '../utils/report_callback_errors';
|
||||
import { subprovider as ganacheSubprovider } from '../utils/subprovider';
|
||||
|
||||
const expect = chai.expect;
|
||||
chaiSetup.configure();
|
||||
@ -18,6 +20,8 @@ describe('RedundantRpcSubprovider', () => {
|
||||
provider = new Web3ProviderEngine();
|
||||
const endpoints = ['http://localhost:8545'];
|
||||
const redundantSubprovider = new RedundantRPCSubprovider(endpoints);
|
||||
// Hack: Hot-swap rpc with ganacheSubprovider
|
||||
(redundantSubprovider as any)._rpcs = [ganacheSubprovider];
|
||||
provider.addProvider(redundantSubprovider);
|
||||
provider.start();
|
||||
|
||||
@ -38,6 +42,11 @@ describe('RedundantRpcSubprovider', () => {
|
||||
provider = new Web3ProviderEngine();
|
||||
const endpoints = ['http://does-not-exist:3000', 'http://localhost:8545'];
|
||||
const redundantSubprovider = new RedundantRPCSubprovider(endpoints);
|
||||
// Hack: Hot-swap rpcs with [nonExistentSubprovider, ganacheSubprovider]
|
||||
const nonExistentSubprovider = new RpcSubprovider({
|
||||
rpcUrl: 'http://does-not-exist:3000',
|
||||
});
|
||||
(redundantSubprovider as any)._rpcs = [nonExistentSubprovider, ganacheSubprovider];
|
||||
provider.addProvider(redundantSubprovider);
|
||||
provider.start();
|
||||
|
||||
|
5
packages/subproviders/test/utils/configs.ts
Normal file
5
packages/subproviders/test/utils/configs.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export const configs = {
|
||||
port: 8545,
|
||||
networkId: 50,
|
||||
mnemonic: 'concert load couple harbor equip island argue ramp clarify fence smart topic',
|
||||
};
|
18
packages/subproviders/test/utils/subprovider.ts
Normal file
18
packages/subproviders/test/utils/subprovider.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import * as fs from 'fs';
|
||||
|
||||
import { GanacheSubprovider } from '../../src/subproviders/ganache';
|
||||
import { configs } from '../utils/configs';
|
||||
|
||||
const logger = {
|
||||
log: (arg: any) => {
|
||||
fs.appendFileSync('ganache.log', `${arg}\n`);
|
||||
},
|
||||
};
|
||||
|
||||
export const subprovider = new GanacheSubprovider({
|
||||
logger,
|
||||
verbose: false,
|
||||
port: configs.port,
|
||||
networkId: configs.networkId,
|
||||
mnemonic: configs.mnemonic,
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user