Skip to content

Commit 5c18a84

Browse files
committed
[test] Add support for custom arguments to TestNodeCLI
1 parent e127494 commit 5c18a84

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

test/functional/test_framework/test_node.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,16 @@ class TestNodeCLI():
155155
"""Interface to bitcoin-cli for an individual node"""
156156

157157
def __init__(self, binary, datadir):
158+
self.args = []
158159
self.binary = binary
159160
self.datadir = datadir
161+
self.input = None
162+
163+
def __call__(self, *args, input=None):
164+
# TestNodeCLI is callable with bitcoin-cli command-line args
165+
self.args = [str(arg) for arg in args]
166+
self.input = input
167+
return self
160168

161169
def __getattr__(self, command):
162170
def dispatcher(*args, **kwargs):
@@ -169,9 +177,9 @@ def send_cli(self, command, *args, **kwargs):
169177
pos_args = [str(arg) for arg in args]
170178
named_args = [str(key) + "=" + str(value) for (key, value) in kwargs.items()]
171179
assert not (pos_args and named_args), "Cannot use positional arguments and named arguments in the same bitcoin-cli call"
172-
p_args = [self.binary, "-datadir=" + self.datadir]
180+
p_args = [self.binary, "-datadir=" + self.datadir] + self.args
173181
if named_args:
174182
p_args += ["-named"]
175183
p_args += [command] + pos_args + named_args
176-
cli_output = subprocess.check_output(p_args, universal_newlines=True)
184+
cli_output = subprocess.check_output(p_args, input=self.input, universal_newlines=True)
177185
return json.loads(cli_output, parse_float=decimal.Decimal)

0 commit comments

Comments
 (0)