diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index cef14a678b1..dbf2e6f0639 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 aa3cdf36c1f..d225f18e740 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)