What changed, and why it matters
This commit is a simple code cleanup in Bitcoin Core's internal test framework. It removes a small helper function called get_rpc_proxy and moves its logic directly into the one place that used it. There is no change to Bitcoin's network protocol, wallet handling, consensus rules, or production code. It only affects test infrastructure and does not introduce a security issue.
No security action needed. Treat as ordinary refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch inlines get_rpc_proxy from test/functional/test_framework/util.py into TestNode.create_new_rpc_connection() in test_node.py. The behavior is preserved: an AuthServiceProxy is created with the same URL and timeout, wrapped in coverage.AuthServiceProxyWrapper using the same coverage logfile logic, and the wrapper is returned. Imports are adjusted accordingly. No functional or security-relevant change is present.
Changed components
test/functional/test_framework/test_node.pytest/functional/test_framework/util.pyInspect captured patch +8 / −36
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py
index cef14a67..dbf2e6f0 100755
--- a/test/functional/test_framework/test_node.py
+++ b/test/functional/test_framework/test_node.py
@@ -24,9 +24,11 @@ from collections.abc import Iterable
from pathlib import Path
from .authproxy import (
+ AuthServiceProxy,
JSONRPCException,
serialization_fallback,
)
+from . import coverage
from .messages import NODE_P2P_V2
from .p2p import P2P_SERVICES, P2P_SUBVERSION
from .util import (
@@ -36,7 +38,6 @@ from .util import (
append_config,
delete_cookie_file,
get_auth_cookie,
- get_rpc_proxy,
rpc_port,
wait_until_helper_internal,
p2p_port,
@@ -200,7 +201,7 @@ class TestNode():
self.process = None
self.rpc_connected = False
self._rpc = None # Should usually not be accessed directly in tests to allow for --usecli mode
- self.reuse_http_connections = True # Must be set before calling get_rpc_proxy() i.e. before restarting node
+ self.reuse_http_connections = True # Must be set before create_new_rpc_connection(), i.e. before restarting node
self.url = None
self.log = logging.getLogger('TestFramework.node%d' % i)
# Cache perf subprocesses here by their data output filename.
@@ -320,12 +321,10 @@ class TestNode():
host = self.rpchost
if mode == RPCConnectionType.AUTHPROXY:
rpc_u, rpc_p = get_auth_cookie(self.datadir_path, self.chain)
- rpc = get_rpc_proxy(
- f"http://{rpc_u}:{rpc_p}@{host}:{port}",
- self.index,
- timeout=client_timeout,
- coveragedir=self.coverage_dir,
- )
+ url = f"http://{rpc_u}:{rpc_p}@{host}:{port}"
+ proxy = AuthServiceProxy(url, timeout=int(client_timeout))
+ coverage_logfile = coverage.get_filename(self.coverage_dir, self.index) if self.coverage_dir else None
+ rpc = coverage.AuthServiceProxyWrapper(proxy, url, coverage_logfile)
rpc.auth_service_proxy_instance.reuse_http_connections = self.reuse_http_connections
return rpc
else: # mode==CLI
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py
index aa3cdf36..d225f18e 100644
--- a/test/functional/test_framework/util.py
+++ b/test/functional/test_framework/util.py
@@ -20,8 +20,7 @@ import shlex
import time
import types
-from . import coverage
-from .authproxy import AuthServiceProxy, JSONRPCException
+from .authproxy import JSONRPCException
from .descriptors import descsum_create
from collections.abc import Callable
from typing import Optional, Union
@@ -478,32 +477,6 @@ class PortSeed:
# Must be initialized with a unique integer for each process
n = None
-
-def get_rpc_proxy(url: str, node_number: int, *, timeout: Optional[int]=None, coveragedir: Optional[str]=None) -> coverage.AuthServiceProxyWrapper:
- """
- Args:
- url: URL of the RPC server to call
- node_number: the node number (or id) that this calls to
-
- Kwargs:
- timeout: HTTP timeout in seconds
- coveragedir: Directory
-
- Returns:
- AuthServiceProxy. convenience object for making RPC calls.
-
- """
- proxy_kwargs = {}
- if timeout is not None:
- proxy_kwargs['timeout'] = int(timeout)
-
- proxy = AuthServiceProxy(url, **proxy_kwargs)
-
- coverage_logfile = coverage.get_filename(coveragedir, node_number) if coveragedir else None
-
- return coverage.AuthServiceProxyWrapper(proxy, url, coverage_logfile)
-
-
def p2p_port(n):
assert n <= MAX_NODES
return PORT_MIN + n + (MAX_NODES * PortSeed.n) % (PORT_RANGE - 1 - MAX_NODES)
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.