mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
create a provider stub
This commit is contained in:
parent
3a2190ec3c
commit
be4011c310
25
test/stub/provider.js
Normal file
25
test/stub/provider.js
Normal file
@ -0,0 +1,25 @@
|
||||
const JsonRpcEngine = require('json-rpc-engine')
|
||||
const scaffoldMiddleware = require('eth-json-rpc-middleware/scaffold')
|
||||
|
||||
module.exports = {
|
||||
createEngineForTestData,
|
||||
providerFromEngine,
|
||||
scaffoldMiddleware,
|
||||
createStubedProvider
|
||||
}
|
||||
|
||||
|
||||
function createEngineForTestData () {
|
||||
return new JsonRpcEngine()
|
||||
}
|
||||
|
||||
function providerFromEngine (engine) {
|
||||
const provider = { sendAsync: engine.handle.bind(engine) }
|
||||
return provider
|
||||
}
|
||||
|
||||
function createStubedProvider (resultStub) {
|
||||
const engine = createEngineForTestData()
|
||||
engine.push(scaffoldMiddleware(resultStub))
|
||||
return providerFromEngine(engine)
|
||||
}
|
Loading…
Reference in New Issue
Block a user