aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework/test_node.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/test_framework/test_node.py')
-rwxr-xr-xtest/functional/test_framework/test_node.py40
1 files changed, 19 insertions, 21 deletions
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py
index 87f6196ae6..b6af71d85c 100755
--- a/test/functional/test_framework/test_node.py
+++ b/test/functional/test_framework/test_node.py
@@ -67,7 +67,7 @@ class TestNode():
To make things easier for the test writer, any unrecognised messages will
be dispatched to the RPC connection."""
- def __init__(self, i, datadir, *, chain, rpchost, timewait, timeout_factor, bitcoind, bitcoin_cli, coverage_dir, cwd, extra_conf=None, extra_args=None, use_cli=False, start_perf=False, use_valgrind=False, version=None, descriptors=False):
+ def __init__(self, i, datadir_path, *, chain, rpchost, timewait, timeout_factor, bitcoind, bitcoin_cli, coverage_dir, cwd, extra_conf=None, extra_args=None, use_cli=False, start_perf=False, use_valgrind=False, version=None, descriptors=False):
"""
Kwargs:
start_perf (bool): If True, begin profiling the node with `perf` as soon as
@@ -76,10 +76,10 @@ class TestNode():
self.index = i
self.p2p_conn_index = 1
- self.datadir = datadir
- self.bitcoinconf = os.path.join(self.datadir, "bitcoin.conf")
- self.stdout_dir = os.path.join(self.datadir, "stdout")
- self.stderr_dir = os.path.join(self.datadir, "stderr")
+ self.datadir_path = datadir_path
+ self.bitcoinconf = self.datadir_path / "bitcoin.conf"
+ self.stdout_dir = self.datadir_path / "stdout"
+ self.stderr_dir = self.datadir_path / "stderr"
self.chain = chain
self.rpchost = rpchost
self.rpc_timeout = timewait
@@ -88,7 +88,7 @@ class TestNode():
self.cwd = cwd
self.descriptors = descriptors
if extra_conf is not None:
- append_config(datadir, extra_conf)
+ append_config(self.datadir_path, extra_conf)
# Most callers will just need to add extra args to the standard list below.
# For those callers that need more flexibility, they can just set the args property directly.
# Note that common args are set in the config file (see initialize_datadir)
@@ -99,7 +99,7 @@ class TestNode():
# spam debug.log.
self.args = [
self.binary,
- "-datadir=" + self.datadir,
+ f"-datadir={self.datadir_path}",
"-logtimemicros",
"-debug",
"-debugexclude=libevent",
@@ -110,10 +110,9 @@ class TestNode():
if self.descriptors is None:
self.args.append("-disablewallet")
- if use_valgrind:
- default_suppressions_file = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- "..", "..", "..", "contrib", "valgrind.supp")
+ # Use valgrind, expect for previous release binaries
+ if use_valgrind and version is None:
+ default_suppressions_file = Path(__file__).parents[3] / "contrib" / "valgrind.supp"
suppressions_file = os.getenv("VALGRIND_SUPPRESSIONS_FILE",
default_suppressions_file)
self.args = ["valgrind", "--suppressions={}".format(suppressions_file),
@@ -127,7 +126,7 @@ class TestNode():
if self.version_is_at_least(239000):
self.args.append("-loglevel=trace")
- self.cli = TestNodeCLI(bitcoin_cli, self.datadir)
+ self.cli = TestNodeCLI(bitcoin_cli, self.datadir_path)
self.use_cli = use_cli
self.start_perf = start_perf
@@ -213,7 +212,7 @@ class TestNode():
# Delete any existing cookie file -- if such a file exists (eg due to
# unclean shutdown), it will get overwritten anyway by bitcoind, and
# potentially interfere with our attempt to authenticate
- delete_cookie_file(self.datadir, self.chain)
+ delete_cookie_file(self.datadir_path, self.chain)
# add environment variable LIBC_FATAL_STDERR_=1 so that libc errors are written to stderr and not the terminal
subp_env = dict(os.environ, LIBC_FATAL_STDERR_="1")
@@ -243,7 +242,7 @@ class TestNode():
f'bitcoind exited with status {self.process.returncode} during initialization. {str_error}'))
try:
rpc = get_rpc_proxy(
- rpc_url(self.datadir, self.index, self.chain, self.rpchost),
+ rpc_url(self.datadir_path, self.index, self.chain, self.rpchost),
self.index,
timeout=self.rpc_timeout // 2, # Shorter timeout to allow for one retry in case of ETIMEDOUT
coveragedir=self.coverage_dir,
@@ -307,7 +306,7 @@ class TestNode():
poll_per_s = 4
for _ in range(poll_per_s * self.rpc_timeout):
try:
- get_auth_cookie(self.datadir, self.chain)
+ get_auth_cookie(self.datadir_path, self.chain)
self.log.debug("Cookie credentials successfully retrieved")
return
except ValueError: # cookie file not found and no rpcuser or rpcpassword; bitcoind is still starting
@@ -425,10 +424,6 @@ class TestNode():
conf.write(conf_data)
@property
- def datadir_path(self) -> Path:
- return Path(self.datadir)
-
- @property
def chain_path(self) -> Path:
return self.datadir_path / self.chain
@@ -453,6 +448,9 @@ class TestNode():
def assert_debug_log(self, expected_msgs, unexpected_msgs=None, timeout=2):
if unexpected_msgs is None:
unexpected_msgs = []
+ assert_equal(type(expected_msgs), list)
+ assert_equal(type(unexpected_msgs), list)
+
time_end = time.time() + timeout * self.timeout_factor
prev_size = self.debug_log_size(encoding="utf-8") # Must use same encoding that is used to read() below
@@ -556,7 +554,7 @@ class TestNode():
"perf output won't be very useful without debug symbols compiled into bitcoind")
output_path = tempfile.NamedTemporaryFile(
- dir=self.datadir,
+ dir=self.datadir_path,
prefix="{}.perf.data.".format(profile_name or 'test'),
delete=False,
).name
@@ -785,7 +783,7 @@ class TestNodeCLI():
"""Run bitcoin-cli command. Deserializes returned string as python object."""
pos_args = [arg_to_cli(arg) for arg in args]
named_args = [str(key) + "=" + arg_to_cli(value) for (key, value) in kwargs.items()]
- p_args = [self.binary, "-datadir=" + self.datadir] + self.options
+ p_args = [self.binary, f"-datadir={self.datadir}"] + self.options
if named_args:
p_args += ["-named"]
if command is not None: