diff options
author | Fabio Berger <me@fabioberger.com> | 2018-04-06 14:46:27 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-04-06 14:46:27 +0800 |
commit | 22fa5a57a588c3c5c2a72ec5ef539797c2847688 (patch) | |
tree | 4ecfb7ff51b4f41213c571c13dcb55b650671b0f /packages/subproviders/test | |
parent | e30c76b7430d8518319eb7d90c7d70ef7c7f6c8d (diff) | |
download | dexon-sol-tools-22fa5a57a588c3c5c2a72ec5ef539797c2847688.tar dexon-sol-tools-22fa5a57a588c3c5c2a72ec5ef539797c2847688.tar.gz dexon-sol-tools-22fa5a57a588c3c5c2a72ec5ef539797c2847688.tar.bz2 dexon-sol-tools-22fa5a57a588c3c5c2a72ec5ef539797c2847688.tar.lz dexon-sol-tools-22fa5a57a588c3c5c2a72ec5ef539797c2847688.tar.xz dexon-sol-tools-22fa5a57a588c3c5c2a72ec5ef539797c2847688.tar.zst dexon-sol-tools-22fa5a57a588c3c5c2a72ec5ef539797c2847688.zip |
Refactor RedundantRpcSubprovider into RedundantSubprovider
Diffstat (limited to 'packages/subproviders/test')
-rw-r--r-- | packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts b/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts index e7ca6d496..e25cb7eb7 100644 --- a/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts +++ b/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts @@ -5,7 +5,8 @@ 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'; @@ -14,14 +15,12 @@ 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); - // Hack: Hot-swap rpc with ganacheSubprovider - (redundantSubprovider as any)._rpcs = [ganacheSubprovider]; + const subproviders = [ganacheSubprovider]; + const redundantSubprovider = new RedundantSubprovider(subproviders); provider.addProvider(redundantSubprovider); provider.start(); @@ -40,13 +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); - // Hack: Hot-swap rpcs with [nonExistentSubprovider, ganacheSubprovider] const nonExistentSubprovider = new RpcSubprovider({ rpcUrl: 'http://does-not-exist:3000', }); - (redundantSubprovider as any)._rpcs = [nonExistentSubprovider, ganacheSubprovider]; + const subproviders = [nonExistentSubprovider as Subprovider, ganacheSubprovider]; + const redundantSubprovider = new RedundantSubprovider(subproviders); provider.addProvider(redundantSubprovider); provider.start(); |