aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-04-04 10:35:58 +0800
committerFabio Berger <me@fabioberger.com>2018-04-04 10:35:58 +0800
commit5e4e27fed5b9b7c889e6e6e1805377b9eff31a3a (patch)
treec6894bbd970482b111498827464f3930e501c212 /packages
parent6c02722f56dd37dd4237248e73d070755f86f318 (diff)
downloaddexon-0x-contracts-5e4e27fed5b9b7c889e6e6e1805377b9eff31a3a.tar
dexon-0x-contracts-5e4e27fed5b9b7c889e6e6e1805377b9eff31a3a.tar.gz
dexon-0x-contracts-5e4e27fed5b9b7c889e6e6e1805377b9eff31a3a.tar.bz2
dexon-0x-contracts-5e4e27fed5b9b7c889e6e6e1805377b9eff31a3a.tar.lz
dexon-0x-contracts-5e4e27fed5b9b7c889e6e6e1805377b9eff31a3a.tar.xz
dexon-0x-contracts-5e4e27fed5b9b7c889e6e6e1805377b9eff31a3a.tar.zst
dexon-0x-contracts-5e4e27fed5b9b7c889e6e6e1805377b9eff31a3a.zip
Update dev-utils and subproviders tests to use ganache in-process provider
Diffstat (limited to 'packages')
-rw-r--r--packages/dev-utils/test/blockchain_lifecycle_test.ts2
-rw-r--r--packages/dev-utils/test/rpc_test.ts2
-rw-r--r--packages/subproviders/test/unit/ledger_subprovider_test.ts7
-rw-r--r--packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts9
-rw-r--r--packages/subproviders/test/utils/configs.ts5
-rw-r--r--packages/subproviders/test/utils/subprovider.ts18
6 files changed, 36 insertions, 7 deletions
diff --git a/packages/dev-utils/test/blockchain_lifecycle_test.ts b/packages/dev-utils/test/blockchain_lifecycle_test.ts
index 5ed67e012..077f6f2f1 100644
--- a/packages/dev-utils/test/blockchain_lifecycle_test.ts
+++ b/packages/dev-utils/test/blockchain_lifecycle_test.ts
@@ -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', () => {
diff --git a/packages/dev-utils/test/rpc_test.ts b/packages/dev-utils/test/rpc_test.ts
index 1bdea3613..233d8035e 100644
--- a/packages/dev-utils/test/rpc_test.ts
+++ b/packages/dev-utils/test/rpc_test.ts
@@ -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 () => {
diff --git a/packages/subproviders/test/unit/ledger_subprovider_test.ts b/packages/subproviders/test/unit/ledger_subprovider_test.ts
index 3cb487f02..a3800434a 100644
--- a/packages/subproviders/test/unit/ledger_subprovider_test.ts
+++ b/packages/subproviders/test/unit/ledger_subprovider_test.ts
@@ -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', () => {
diff --git a/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts b/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts
index a347ab765..ab540e202 100644
--- a/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts
+++ b/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts
@@ -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();
diff --git a/packages/subproviders/test/utils/configs.ts b/packages/subproviders/test/utils/configs.ts
new file mode 100644
index 000000000..341037e4f
--- /dev/null
+++ b/packages/subproviders/test/utils/configs.ts
@@ -0,0 +1,5 @@
+export const configs = {
+ port: 8545,
+ networkId: 50,
+ mnemonic: 'concert load couple harbor equip island argue ramp clarify fence smart topic',
+};
diff --git a/packages/subproviders/test/utils/subprovider.ts b/packages/subproviders/test/utils/subprovider.ts
new file mode 100644
index 000000000..b1c459746
--- /dev/null
+++ b/packages/subproviders/test/utils/subprovider.ts
@@ -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,
+});