test: move out JSONRPCException from authproxy to util
What changed, and why it matters
This is a harmless internal code cleanup in Bitcoin Core's test suite. It moves a Python exception class named JSONRPCException from one test helper file (authproxy.py) to another (util.py) and updates the files that import it. There is no change to how Bitcoin nodes behave, no fix for a security bug, and no change that affects real users or live networks.
No action required. This is a non-security refactoring change in test code only.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors the test framework by relocating JSONRPCException from test_framework/authproxy.py to test_framework/util.py. This reverses the dependency direction: util.py no longer imports from authproxy.py, and authproxy.py now imports from util.py. All functional tests that referenced JSONRPCException from authproxy are updated to import it from util instead. The class definition is copied verbatim, including its constructor and attributes (error, http_status). No runtime logic is modified.
Changed components
test/functional/test_framework/authproxy.pytest/functional/test_framework/util.pytest/functional/test_framework/test_framework.pytest/functional/feature_index_prune.pytest/functional/rpc_getblockfrompeer.pytest/functional/rpc_misc.pytest/functional/wallet_importdescriptors.pytest/functional/wallet_multiwallet.pytest/functional/wallet_send.pytest/functional/wallet_v3_txs.pyInspect captured patch +16 / −17
diff --git a/test/functional/feature_index_prune.py b/test/functional/feature_index_prune.py
index ba4907ac..89c8acd4 100755
--- a/test/functional/feature_index_prune.py
+++ b/test/functional/feature_index_prune.py
@@ -5,13 +5,13 @@
"""Test indices in conjunction with prune."""
import concurrent.futures
import os
-from test_framework.authproxy import JSONRPCException
from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_node import TestNode
from test_framework.util import (
assert_equal,
assert_greater_than,
assert_raises_rpc_error,
+ JSONRPCException,
)
from typing import List, Any
diff --git a/test/functional/rpc_getblockfrompeer.py b/test/functional/rpc_getblockfrompeer.py
index 9adcd88c..f646abed 100755
--- a/test/functional/rpc_getblockfrompeer.py
+++ b/test/functional/rpc_getblockfrompeer.py
@@ -4,7 +4,6 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the getblockfrompeer RPC."""
-from test_framework.authproxy import JSONRPCException
from test_framework.messages import (
CBlock,
from_hex,
@@ -19,6 +18,7 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
+ JSONRPCException,
)
diff --git a/test/functional/rpc_misc.py b/test/functional/rpc_misc.py
index 86f22f00..6e4c908d 100755
--- a/test/functional/rpc_misc.py
+++ b/test/functional/rpc_misc.py
@@ -11,10 +11,9 @@ from test_framework.util import (
assert_equal,
assert_greater_than,
assert_greater_than_or_equal,
+ JSONRPCException,
)
-from test_framework.authproxy import JSONRPCException
-
import http
import subprocess
diff --git a/test/functional/test_framework/authproxy.py b/test/functional/test_framework/authproxy.py
index 078672c3..3d263a64 100644
--- a/test/functional/test_framework/authproxy.py
+++ b/test/functional/test_framework/authproxy.py
@@ -44,18 +44,13 @@ import socket
import time
import urllib.parse
+from .util import JSONRPCException
+
HTTP_TIMEOUT = 30
USER_AGENT = "AuthServiceProxy/0.1"
log = logging.getLogger("BitcoinRPC")
-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
-
-
def serialization_fallback(o):
if isinstance(o, decimal.Decimal):
return str(o)
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index 549e6ff6..ad75076d 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -22,7 +22,6 @@ import tempfile
import time
from .address import create_deterministic_address_bcrt1_p2tr_op_true
-from .authproxy import JSONRPCException
from . import coverage
from .p2p import NetworkThread
from .test_node import TestNode
@@ -40,6 +39,7 @@ from .util import (
p2p_port,
wait_until_helper_internal,
wallet_importprivkey,
+ JSONRPCException,
)
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py
index d225f18e..ee8061fd 100644
--- a/test/functional/test_framework/util.py
+++ b/test/functional/test_framework/util.py
@@ -20,7 +20,6 @@ import shlex
import time
import types
-from .authproxy import JSONRPCException
from .descriptors import descsum_create
from collections.abc import Callable
from typing import Optional, Union
@@ -29,6 +28,12 @@ SATOSHI_PRECISION = Decimal('0.00000001')
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
+
# Assert functions
##################
diff --git a/test/functional/wallet_importdescriptors.py b/test/functional/wallet_importdescriptors.py
index 3e8b05a2..9a3a1802 100755
--- a/test/functional/wallet_importdescriptors.py
+++ b/test/functional/wallet_importdescriptors.py
@@ -18,7 +18,6 @@ variants.
import concurrent.futures
import time
-from test_framework.authproxy import JSONRPCException
from test_framework.blocktools import COINBASE_MATURITY
from test_framework.test_framework import BitcoinTestFramework
from test_framework.descriptors import descsum_create
@@ -26,6 +25,7 @@ from test_framework.script import SEQUENCE_LOCKTIME_TYPE_FLAG
from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
+ JSONRPCException,
)
from test_framework.wallet_util import (
get_generate_key,
diff --git a/test/functional/wallet_multiwallet.py b/test/functional/wallet_multiwallet.py
index 4f855ee0..db865281 100755
--- a/test/functional/wallet_multiwallet.py
+++ b/test/functional/wallet_multiwallet.py
@@ -12,7 +12,6 @@ import platform
import shutil
import stat
-from test_framework.authproxy import JSONRPCException
from test_framework.blocktools import COINBASE_MATURITY
from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_node import ErrorMatch
@@ -20,6 +19,7 @@ from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
ensure_for,
+ JSONRPCException,
)
got_loading_error = False
diff --git a/test/functional/wallet_send.py b/test/functional/wallet_send.py
index ba986990..f3784778 100755
--- a/test/functional/wallet_send.py
+++ b/test/functional/wallet_send.py
@@ -7,7 +7,6 @@
from decimal import Decimal, getcontext
from itertools import product
-from test_framework.authproxy import JSONRPCException
from test_framework.descriptors import descsum_create
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
@@ -18,6 +17,7 @@ from test_framework.util import (
assert_greater_than_or_equal,
assert_raises_rpc_error,
count_bytes,
+ JSONRPCException,
)
from test_framework.wallet_util import (
calculate_input_weight,
diff --git a/test/functional/wallet_v3_txs.py b/test/functional/wallet_v3_txs.py
index 18fa0d54..6ba30de4 100755
--- a/test/functional/wallet_v3_txs.py
+++ b/test/functional/wallet_v3_txs.py
@@ -6,7 +6,6 @@
from decimal import Decimal, getcontext
-from test_framework.authproxy import JSONRPCException
from test_framework.messages import (
COIN,
CTransaction,
@@ -28,6 +27,7 @@ from test_framework.util import (
assert_equal,
assert_greater_than,
assert_raises_rpc_error,
+ JSONRPCException,
)
from test_framework.mempool_util import (
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.