mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-11 21:20:39 +02:00
test: Map cli CalledProcessError on server error to JSONRPCException
Like authproxy.py, so that tests can work without having to think whether the cli was used or not.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user