Skip to content

Commit e3e1a56

Browse files
committed
[test] functional: set cwd of nodes to tmpdir
1 parent c576979 commit e3e1a56

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

test/functional/test_framework/test_framework.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ def add_nodes(self, num_nodes, extra_args=None, *, rpchost=None, binary=None):
318318
bitcoin_cli=self.options.bitcoincli,
319319
mocktime=self.mocktime,
320320
coverage_dir=self.options.coveragedir,
321+
cwd=self.options.tmpdir,
321322
extra_conf=extra_confs[i],
322323
extra_args=extra_args[i],
323324
use_cli=self.options.usecli,
@@ -469,6 +470,7 @@ def _initialize_chain(self):
469470
bitcoin_cli=self.options.bitcoincli,
470471
mocktime=self.mocktime,
471472
coverage_dir=None,
473+
cwd=self.options.tmpdir,
472474
))
473475
self.nodes[i].args = args
474476
self.start_node(i)

test/functional/test_framework/test_node.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class TestNode():
6161
To make things easier for the test writer, any unrecognised messages will
6262
be dispatched to the RPC connection."""
6363

64-
def __init__(self, i, datadir, *, rpchost, timewait, bitcoind, bitcoin_cli, mocktime, coverage_dir, extra_conf=None, extra_args=None, use_cli=False, start_perf=False):
64+
def __init__(self, i, datadir, *, rpchost, timewait, bitcoind, bitcoin_cli, mocktime, coverage_dir, cwd, extra_conf=None, extra_args=None, use_cli=False, start_perf=False):
6565
"""
6666
Kwargs:
6767
start_perf (bool): If True, begin profiling the node with `perf` as soon as
@@ -76,6 +76,7 @@ def __init__(self, i, datadir, *, rpchost, timewait, bitcoind, bitcoin_cli, mock
7676
self.rpc_timeout = timewait
7777
self.binary = bitcoind
7878
self.coverage_dir = coverage_dir
79+
self.cwd = cwd
7980
if extra_conf is not None:
8081
append_config(datadir, extra_conf)
8182
# Most callers will just need to add extra args to the standard list below.
@@ -171,7 +172,7 @@ def __getattr__(self, name):
171172
assert self.rpc_connected and self.rpc is not None, self._node_msg("Error: no RPC connection")
172173
return getattr(self.rpc, name)
173174

174-
def start(self, extra_args=None, *, stdout=None, stderr=None, **kwargs):
175+
def start(self, extra_args=None, *, cwd=None, stdout=None, stderr=None, **kwargs):
175176
"""Start the node."""
176177
if extra_args is None:
177178
extra_args = self.extra_args
@@ -184,6 +185,9 @@ def start(self, extra_args=None, *, stdout=None, stderr=None, **kwargs):
184185
self.stderr = stderr
185186
self.stdout = stdout
186187

188+
if cwd is None:
189+
cwd = self.cwd
190+
187191
# Delete any existing cookie file -- if such a file exists (eg due to
188192
# unclean shutdown), it will get overwritten anyway by bitcoind, and
189193
# potentially interfere with our attempt to authenticate
@@ -192,7 +196,7 @@ def start(self, extra_args=None, *, stdout=None, stderr=None, **kwargs):
192196
# add environment variable LIBC_FATAL_STDERR_=1 so that libc errors are written to stderr and not the terminal
193197
subp_env = dict(os.environ, LIBC_FATAL_STDERR_="1")
194198

195-
self.process = subprocess.Popen(self.args + extra_args, env=subp_env, stdout=stdout, stderr=stderr, **kwargs)
199+
self.process = subprocess.Popen(self.args + extra_args, env=subp_env, stdout=stdout, stderr=stderr, cwd=cwd, **kwargs)
196200

197201
self.running = True
198202
self.log.debug("bitcoind started, waiting for RPC to come up")

0 commit comments

Comments
 (0)