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:
rkrux
2026-05-26 20:14:47 +05:30
parent 9ec4efebd1
commit ac09260982

View File

@@ -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
##################