Changeset View
Changeset View
Standalone View
Standalone View
test/functional/test_framework/test_node.py
Show All 23 Lines | from .util import ( | ||||
append_config, | append_config, | ||||
delete_cookie_file, | delete_cookie_file, | ||||
get_rpc_proxy, | get_rpc_proxy, | ||||
p2p_port, | p2p_port, | ||||
rpc_url, | rpc_url, | ||||
wait_until, | wait_until, | ||||
) | ) | ||||
# For Python 3.4 compatibility | |||||
JSONDecodeError = getattr(json, "JSONDecodeError", ValueError) | |||||
BITCOIND_PROC_WAIT_TIMEOUT = 60 | BITCOIND_PROC_WAIT_TIMEOUT = 60 | ||||
class FailedToStartError(Exception): | class FailedToStartError(Exception): | ||||
"""Raised when a node fails to start correctly.""" | """Raised when a node fails to start correctly.""" | ||||
class ErrorMatch(Enum): | class ErrorMatch(Enum): | ||||
▲ Show 20 Lines • Show All 410 Lines • ▼ Show 20 Lines | def send_cli(self, command=None, *args, **kwargs): | ||||
if match: | if match: | ||||
code, message = match.groups() | code, message = match.groups() | ||||
raise JSONRPCException(dict(code=int(code), message=message)) | raise JSONRPCException(dict(code=int(code), message=message)) | ||||
# Ignore cli_stdout, raise with cli_stderr | # Ignore cli_stdout, raise with cli_stderr | ||||
raise subprocess.CalledProcessError( | raise subprocess.CalledProcessError( | ||||
returncode, self.binary, output=cli_stderr) | returncode, self.binary, output=cli_stderr) | ||||
try: | try: | ||||
return json.loads(cli_stdout, parse_float=decimal.Decimal) | return json.loads(cli_stdout, parse_float=decimal.Decimal) | ||||
except JSONDecodeError: | except json.JSONDecodeError: | ||||
return cli_stdout.rstrip("\n") | return cli_stdout.rstrip("\n") |