aboutsummaryrefslogtreecommitdiffstats
path: root/packages/subproviders/test
diff options
context:
space:
mode:
Diffstat (limited to 'packages/subproviders/test')
-rw-r--r--packages/subproviders/test/integration/ledger_subprovider_test.ts2
-rw-r--r--packages/subproviders/test/unit/ledger_subprovider_test.ts7
-rw-r--r--packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts18
-rw-r--r--packages/subproviders/test/utils/configs.ts5
-rw-r--r--packages/subproviders/test/utils/ganache_subprovider.ts18
5 files changed, 38 insertions, 12 deletions
diff --git a/packages/subproviders/test/integration/ledger_subprovider_test.ts b/packages/subproviders/test/integration/ledger_subprovider_test.ts
index 11b5f6410..0d6e67bd1 100644
--- a/packages/subproviders/test/integration/ledger_subprovider_test.ts
+++ b/packages/subproviders/test/integration/ledger_subprovider_test.ts
@@ -1,7 +1,7 @@
import { JSONRPCResponsePayload } from '@0xproject/types';
import { promisify } from '@0xproject/utils';
import Eth from '@ledgerhq/hw-app-eth';
-// HACK: This depdency is optional and tslint skips optional depdencies
+// HACK: This dependency is optional and tslint skips optional dependencies
// tslint:disable-next-line:no-implicit-dependencies
import TransportNodeHid from '@ledgerhq/hw-transport-node-hid';
import * as chai from 'chai';
diff --git a/packages/subproviders/test/unit/ledger_subprovider_test.ts b/packages/subproviders/test/unit/ledger_subprovider_test.ts
index ad1154831..892c2acd0 100644
--- a/packages/subproviders/test/unit/ledger_subprovider_test.ts
+++ b/packages/subproviders/test/unit/ledger_subprovider_test.ts
@@ -4,7 +4,6 @@ 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 {
@@ -15,6 +14,7 @@ import {
} from '../../src/types';
import { chaiSetup } from '../chai_setup';
import { fixtureData } from '../utils/fixture_data';
+import { ganacheSubprovider } from '../utils/ganache_subprovider';
import { reportCallbackErrors } from '../utils/report_callback_errors';
chaiSetup.configure();
@@ -105,10 +105,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..e25cb7eb7 100644
--- a/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts
+++ b/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts
@@ -3,21 +3,24 @@ 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 { RedundantSubprovider } from '../../src';
+import { Subprovider } from '../../src/subproviders/subprovider';
import { DoneCallback } from '../../src/types';
import { chaiSetup } from '../chai_setup';
+import { ganacheSubprovider } from '../utils/ganache_subprovider';
import { reportCallbackErrors } from '../utils/report_callback_errors';
const expect = chai.expect;
chaiSetup.configure();
-describe('RedundantRpcSubprovider', () => {
+describe('RedundantSubprovider', () => {
let provider: Web3ProviderEngine;
it('succeeds when supplied a healthy endpoint', (done: DoneCallback) => {
provider = new Web3ProviderEngine();
- const endpoints = ['http://localhost:8545'];
- const redundantSubprovider = new RedundantRPCSubprovider(endpoints);
+ const subproviders = [ganacheSubprovider];
+ const redundantSubprovider = new RedundantSubprovider(subproviders);
provider.addProvider(redundantSubprovider);
provider.start();
@@ -36,8 +39,11 @@ describe('RedundantRpcSubprovider', () => {
});
it('succeeds when supplied at least one healthy endpoint', (done: DoneCallback) => {
provider = new Web3ProviderEngine();
- const endpoints = ['http://does-not-exist:3000', 'http://localhost:8545'];
- const redundantSubprovider = new RedundantRPCSubprovider(endpoints);
+ const nonExistentSubprovider = new RpcSubprovider({
+ rpcUrl: 'http://does-not-exist:3000',
+ });
+ const subproviders = [nonExistentSubprovider as Subprovider, ganacheSubprovider];
+ const redundantSubprovider = new RedundantSubprovider(subproviders);
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/ganache_subprovider.ts b/packages/subproviders/test/utils/ganache_subprovider.ts
new file mode 100644
index 000000000..ac4a9325c
--- /dev/null
+++ b/packages/subproviders/test/utils/ganache_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 ganacheSubprovider = new GanacheSubprovider({
+ logger,
+ verbose: false,
+ port: configs.port,
+ networkId: configs.networkId,
+ mnemonic: configs.mnemonic,
+});