aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2017-12-21 04:54:43 -0500
committerJohn Newbery <john@johnnewbery.com>2018-01-08 15:17:14 -0500
commitff9a363ff70e1b72a1283098e69bbe14d1c16bcc (patch)
treef3188bfaa69bbd1d481076dc5b51807a3119d236
parentca9085afc53eb20c1fc745ae469e9587a05b7f24 (diff)
downloadbitcoin-ff9a363ff70e1b72a1283098e69bbe14d1c16bcc.tar.xz
TestNodeCLI batch emulation
Support same get_request and batch methods as AuthServiceProxy
-rwxr-xr-xtest/functional/test_framework/test_node.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py
index 1723f50eba..fd44bff32b 100755
--- a/test/functional/test_framework/test_node.py
+++ b/test/functional/test_framework/test_node.py
@@ -191,6 +191,16 @@ class TestNode():
p.peer_disconnect()
del self.p2ps[:]
+class TestNodeCLIAttr:
+ def __init__(self, cli, command):
+ self.cli = cli
+ self.command = command
+
+ def __call__(self, *args, **kwargs):
+ return self.cli.send_cli(self.command, *args, **kwargs)
+
+ def get_request(self, *args, **kwargs):
+ return lambda: self(*args, **kwargs)
class TestNodeCLI():
"""Interface to bitcoin-cli for an individual node"""
@@ -209,9 +219,16 @@ class TestNodeCLI():
return cli
def __getattr__(self, command):
- def dispatcher(*args, **kwargs):
- return self.send_cli(command, *args, **kwargs)
- return dispatcher
+ return TestNodeCLIAttr(self, command)
+
+ def batch(self, requests):
+ results = []
+ for request in requests:
+ try:
+ results.append(dict(result=request()))
+ except JSONRPCException as e:
+ results.append(dict(error=e))
+ return results
def send_cli(self, command, *args, **kwargs):
"""Run bitcoin-cli command. Deserializes returned string as python object."""