mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
[test] Add support for custom arguments to TestNodeCLI
This commit is contained in:
parent
d446cc57aa
commit
6245ce95e1
@ -158,8 +158,16 @@ class TestNodeCLI():
|
||||
"""Interface to bitcoin-cli for an individual node"""
|
||||
|
||||
def __init__(self, binary, datadir):
|
||||
self.args = []
|
||||
self.binary = binary
|
||||
self.datadir = datadir
|
||||
self.input = None
|
||||
|
||||
def __call__(self, *args, input=None):
|
||||
# TestNodeCLI is callable with bitcoin-cli command-line args
|
||||
self.args = [str(arg) for arg in args]
|
||||
self.input = input
|
||||
return self
|
||||
|
||||
def __getattr__(self, command):
|
||||
def dispatcher(*args, **kwargs):
|
||||
@ -172,9 +180,9 @@ class TestNodeCLI():
|
||||
pos_args = [str(arg) for arg in args]
|
||||
named_args = [str(key) + "=" + str(value) for (key, value) in kwargs.items()]
|
||||
assert not (pos_args and named_args), "Cannot use positional arguments and named arguments in the same bitcoin-cli call"
|
||||
p_args = [self.binary, "-datadir=" + self.datadir]
|
||||
p_args = [self.binary, "-datadir=" + self.datadir] + self.args
|
||||
if named_args:
|
||||
p_args += ["-named"]
|
||||
p_args += [command] + pos_args + named_args
|
||||
cli_output = subprocess.check_output(p_args, universal_newlines=True)
|
||||
cli_output = subprocess.check_output(p_args, input=self.input, universal_newlines=True)
|
||||
return json.loads(cli_output, parse_float=decimal.Decimal)
|
||||
|
Loading…
Reference in New Issue
Block a user