@@ -155,8 +155,16 @@ class TestNodeCLI():
155
155
"""Interface to bitcoin-cli for an individual node"""
156
156
157
157
def __init__ (self , binary , datadir ):
158
+ self .args = []
158
159
self .binary = binary
159
160
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
160
168
161
169
def __getattr__ (self , command ):
162
170
def dispatcher (* args , ** kwargs ):
@@ -169,9 +177,9 @@ def send_cli(self, command, *args, **kwargs):
169
177
pos_args = [str (arg ) for arg in args ]
170
178
named_args = [str (key ) + "=" + str (value ) for (key , value ) in kwargs .items ()]
171
179
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
173
181
if named_args :
174
182
p_args += ["-named" ]
175
183
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 )
177
185
return json .loads (cli_output , parse_float = decimal .Decimal )
0 commit comments