aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2018-01-15 06:00:59 +0800
committerfrankiebee <frankie.diamond@gmail.com>2018-01-15 06:00:59 +0800
commit409b49b411fee4c3f6f9106d99e2bba915bb5f0f (patch)
tree844a09d7504fa959f44f7cf5ab6a6624712c5e13 /test
parentf0dd4f19238d63875fbdfa3a9b31fa7b9d8925ed (diff)
downloadtangerine-wallet-browser-409b49b411fee4c3f6f9106d99e2bba915bb5f0f.tar
tangerine-wallet-browser-409b49b411fee4c3f6f9106d99e2bba915bb5f0f.tar.gz
tangerine-wallet-browser-409b49b411fee4c3f6f9106d99e2bba915bb5f0f.tar.bz2
tangerine-wallet-browser-409b49b411fee4c3f6f9106d99e2bba915bb5f0f.tar.lz
tangerine-wallet-browser-409b49b411fee4c3f6f9106d99e2bba915bb5f0f.tar.xz
tangerine-wallet-browser-409b49b411fee4c3f6f9106d99e2bba915bb5f0f.tar.zst
tangerine-wallet-browser-409b49b411fee4c3f6f9106d99e2bba915bb5f0f.zip
test - create ethJsQuery stub
Diffstat (limited to 'test')
-rw-r--r--test/stub/provider.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/test/stub/provider.js b/test/stub/provider.js
index 8a306f6d9..85e1da707 100644
--- a/test/stub/provider.js
+++ b/test/stub/provider.js
@@ -5,7 +5,8 @@ module.exports = {
createEngineForTestData,
providerFromEngine,
scaffoldMiddleware,
- createStubedProvider
+ createEthJsQueryStub,
+ createStubedProvider,
}
@@ -18,6 +19,18 @@ function providerFromEngine (engine) {
return provider
}
+function createEthJsQueryStub (stubProvider) {
+ return new Proxy({}, {
+ get: (obj, method) => {
+ return (...params) => {
+ return new Promise((resolve, reject) => {
+ stubProvider.sendAsync({ method: `eth_${method}`, params }, (err, ress) => resolve(ress.result))
+ })
+ }
+ },
+ })
+}
+
function createStubedProvider (resultStub) {
const engine = createEngineForTestData()
engine.push(scaffoldMiddleware(resultStub))