diff options
test - createTestProviderTools includes block tracker layer
Diffstat (limited to 'test/stub')
-rw-r--r-- | test/stub/provider.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/test/stub/provider.js b/test/stub/provider.js index e1e6ffce6..e77db4e28 100644 --- a/test/stub/provider.js +++ b/test/stub/provider.js @@ -1,11 +1,12 @@ const JsonRpcEngine = require('json-rpc-engine') const scaffoldMiddleware = require('eth-json-rpc-middleware/scaffold') +const TestBlockchain = require('eth-block-tracker/test/util/testBlockMiddleware') module.exports = { createEngineForTestData, providerFromEngine, scaffoldMiddleware, - createStubbedProvider, + createTestProviderTools, } @@ -18,8 +19,13 @@ function providerFromEngine (engine) { return provider } -function createStubbedProvider (resultStub) { +function createTestProviderTools (opts = {}) { const engine = createEngineForTestData() - engine.push(scaffoldMiddleware(resultStub)) - return providerFromEngine(engine) + const testBlockchain = new TestBlockchain() + // handle provided hooks + engine.push(scaffoldMiddleware(opts.scaffold || {})) + // handle block tracker methods + engine.push(testBlockchain.createMiddleware()) + const provider = providerFromEngine(engine) + return { provider, engine, testBlockchain } } |