aboutsummaryrefslogtreecommitdiffstats
path: root/test/stub
diff options
context:
space:
mode:
Diffstat (limited to 'test/stub')
-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))