mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-02 09:15:04 +02:00
test: restore JSONRPCException error format
This is a follow-up to PR 34575. Copy is done so that checking of error["code"] in test_node.py while handling this exception doesn't fail. Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
"""Helpful routines for regression testing."""
|
||||
|
||||
from base64 import b64encode
|
||||
from copy import copy
|
||||
from decimal import Decimal
|
||||
from subprocess import CalledProcessError
|
||||
import hashlib
|
||||
@@ -30,10 +31,16 @@ logger = logging.getLogger("TestFramework.utils")
|
||||
|
||||
class JSONRPCException(Exception):
|
||||
def __init__(self, rpc_error, http_status=None):
|
||||
super().__init__(f"{rpc_error} [http_status={http_status}]")
|
||||
self.error = rpc_error
|
||||
self.http_status = http_status
|
||||
|
||||
# throw KeyError if any required fields are missing
|
||||
copied_error = copy(rpc_error)
|
||||
message = copied_error.pop("message")
|
||||
code = copied_error.pop("code")
|
||||
extra = f'{copied_error}' if copied_error else ''
|
||||
super().__init__(f"{message} ({code}) {extra} [http_status={http_status}]")
|
||||
|
||||
# Assert functions
|
||||
##################
|
||||
|
||||
|
||||
Reference in New Issue
Block a user