diff --git a/test/functional/interface_rpc.py b/test/functional/interface_rpc.py index 46dbd2f809d..d9636c122ad 100755 --- a/test/functional/interface_rpc.py +++ b/test/functional/interface_rpc.py @@ -8,10 +8,9 @@ import json import os from dataclasses import dataclass from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, assert_greater_than_or_equal +from test_framework.util import JSONRPCException, assert_equal, assert_greater_than_or_equal from threading import Thread from typing import Optional -import subprocess RPC_INVALID_PARAMETER = -8 @@ -83,8 +82,8 @@ def test_work_queue_getblock(node, got_exceeded_error): while not got_exceeded_error: try: node.cli("waitfornewblock", "500").send_cli() - except subprocess.CalledProcessError as e: - assert_equal(e.output, 'error: Server response: Work queue depth exceeded\n') + except JSONRPCException as e: + assert_equal(e.error["message"], "non-JSON HTTP response with '503 Service Unavailable' from server: Work queue depth exceeded") got_exceeded_error.append(True) diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index 24c76564862..0308c5466b8 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -967,6 +967,13 @@ class TestNodeCLI(): if match: code, message = match.groups() raise JSONRPCException(dict(code=int(code), message=message)) + match = re.match(r'error: Server response: (.*)\n?$', cli_stderr) + if match: + message = match.group(1) + raise JSONRPCException(dict( + code=-342, + message=f"non-JSON HTTP response with '503 Service Unavailable' from server: {message}", + ), http_status=503) # Ignore cli_stdout, raise with cli_stderr raise subprocess.CalledProcessError(returncode, p_args, output=cli_stderr) try: