aboutsummaryrefslogtreecommitdiffstats
path: root/test/stub
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2017-08-09 06:30:03 +0800
committerfrankiebee <frankie.diamond@gmail.com>2017-08-09 06:30:03 +0800
commitbe4011c310eab76d3010da2e6354a953396f85f5 (patch)
tree354ccbcb50056642aa7ff4dedbbf6f75b9625dd7 /test/stub
parent3a2190ec3cac0211d37dab6434d29f7bb484d4c4 (diff)
downloadtangerine-wallet-browser-be4011c310eab76d3010da2e6354a953396f85f5.tar.gz
tangerine-wallet-browser-be4011c310eab76d3010da2e6354a953396f85f5.tar.zst
tangerine-wallet-browser-be4011c310eab76d3010da2e6354a953396f85f5.zip
create a provider stub
Diffstat (limited to 'test/stub')
-rw-r--r--test/stub/provider.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/stub/provider.js b/test/stub/provider.js
new file mode 100644
index 000000000..8a306f6d9
--- /dev/null
+++ b/test/stub/provider.js
@@ -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)
+} \ No newline at end of file