Skip to content

Commit 126000b

Browse files
author
MarcoFalke
committed
Merge #12089: qa: Make TestNodeCLI command optional in send_cli
fae7b14 qa: Make TestNodeCLI command optional in send_cli (MarcoFalke) ffffb10 qa: Rename cli.args to cli.options (MarcoFalke) Pull request description: Makes the `command` optional, since there are valid bitcoin-cli calls that have no `command`: * `bitcoin-cli -?` * `bitcoin-cli -getinfo` * ... Also, rename self.args to self.options, since that is the name in the `bitcoin-cli -help` documentation. Tree-SHA512: f49c06024e78423301d70782946d47c0fb97a26876afba0a1f71ed329f5d7124aee4c2df520c7af74079bf9937851902f7be9c54abecc28dc29274584804d46c
2 parents 69ec021 + fae7b14 commit 126000b

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

test/functional/bitcoin_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def run_test(self):
3939
assert_raises_process_error(1, "-getinfo takes no arguments", self.nodes[0].cli('-getinfo').help)
4040

4141
self.log.info("Compare responses from `bitcoin-cli -getinfo` and the RPCs data is retrieved from.")
42-
cli_get_info = self.nodes[0].cli().send_cli('-getinfo')
42+
cli_get_info = self.nodes[0].cli('-getinfo').send_cli()
4343
wallet_info = self.nodes[0].getwalletinfo()
4444
network_info = self.nodes[0].getnetworkinfo()
4545
blockchain_info = self.nodes[0].getblockchaininfo()

test/functional/test_framework/test_node.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,16 @@ class TestNodeCLI():
213213
"""Interface to bitcoin-cli for an individual node"""
214214

215215
def __init__(self, binary, datadir):
216-
self.args = []
216+
self.options = []
217217
self.binary = binary
218218
self.datadir = datadir
219219
self.input = None
220220
self.log = logging.getLogger('TestFramework.bitcoincli')
221221

222-
def __call__(self, *args, input=None):
223-
# TestNodeCLI is callable with bitcoin-cli command-line args
222+
def __call__(self, *options, input=None):
223+
# TestNodeCLI is callable with bitcoin-cli command-line options
224224
cli = TestNodeCLI(self.binary, self.datadir)
225-
cli.args = [str(arg) for arg in args]
225+
cli.options = [str(o) for o in options]
226226
cli.input = input
227227
return cli
228228

@@ -238,16 +238,18 @@ def batch(self, requests):
238238
results.append(dict(error=e))
239239
return results
240240

241-
def send_cli(self, command, *args, **kwargs):
241+
def send_cli(self, command=None, *args, **kwargs):
242242
"""Run bitcoin-cli command. Deserializes returned string as python object."""
243243

244244
pos_args = [str(arg) for arg in args]
245245
named_args = [str(key) + "=" + str(value) for (key, value) in kwargs.items()]
246246
assert not (pos_args and named_args), "Cannot use positional arguments and named arguments in the same bitcoin-cli call"
247-
p_args = [self.binary, "-datadir=" + self.datadir] + self.args
247+
p_args = [self.binary, "-datadir=" + self.datadir] + self.options
248248
if named_args:
249249
p_args += ["-named"]
250-
p_args += [command] + pos_args + named_args
250+
if command is not None:
251+
p_args += [command]
252+
p_args += pos_args + named_args
251253
self.log.debug("Running bitcoin-cli command: %s" % command)
252254
process = subprocess.Popen(p_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
253255
cli_stdout, cli_stderr = process.communicate(input=self.input)

0 commit comments

Comments
 (0)