test: move out JSONRPCException from authproxy to util

So that util is not dependent on authproxy at all and going
forward authproxy can use util methods.

Reviewing with --color-moved=dimmed-zebra option can be helpful.
This commit is contained in:
rkrux
2026-04-11 12:46:35 +05:30
parent de925455c8
commit 779f444680
10 changed files with 16 additions and 17 deletions

View File

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

View File

@@ -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,
)

View File

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

View File

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

View File

@@ -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,
)

View File

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

View File

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

View File

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

View File

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

View File

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