Skip to content

Commit 5566405

Browse files
committed
Merge bitcoin/bitcoin#27554: test: Treat bitcoin-wallet binary in the same way as others
f6d7636 test: Treat `bitcoin-wallet` binary in the same way as others (Hennadii Stepanov) dda961c test, refactor: Add `set_binary_paths` function (Hennadii Stepanov) Pull request description: This PR makes the `bitcoin-wallet` binary path customizable in the same way how it can be done now with other ones, including `bitcoind`, `bitcoin-cli` and `bitcoin-util`. ACKs for top commit: stickies-v: re-ACK f6d7636 Tree-SHA512: 480fae14c5440e530ba78a2be19eaaf642260070435e533fc7ab98ddcc2fcac7ad83f2c7e7c6706db3167e8391d7d4abf8784889796c218c2d5bba043144e787
2 parents b11bd04 + f6d7636 commit 5566405

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

test/functional/test_framework/test_framework.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,23 @@ def parse_args(self):
228228

229229
PortSeed.n = self.options.port_seed
230230

231+
def set_binary_paths(self):
232+
"""Update self.options with the paths of all binaries from environment variables or their default values"""
233+
234+
binaries = {
235+
"bitcoind": ("bitcoind", "BITCOIND"),
236+
"bitcoin-cli": ("bitcoincli", "BITCOINCLI"),
237+
"bitcoin-util": ("bitcoinutil", "BITCOINUTIL"),
238+
"bitcoin-wallet": ("bitcoinwallet", "BITCOINWALLET"),
239+
}
240+
for binary, [attribute_name, env_variable_name] in binaries.items():
241+
default_filename = os.path.join(
242+
self.config["environment"]["BUILDDIR"],
243+
"src",
244+
binary + self.config["environment"]["EXEEXT"],
245+
)
246+
setattr(self.options, attribute_name, os.getenv(env_variable_name, default=default_filename))
247+
231248
def setup(self):
232249
"""Call this method to start up the test framework object with options set."""
233250

@@ -237,24 +254,7 @@ def setup(self):
237254

238255
config = self.config
239256

240-
fname_bitcoind = os.path.join(
241-
config["environment"]["BUILDDIR"],
242-
"src",
243-
"bitcoind" + config["environment"]["EXEEXT"],
244-
)
245-
fname_bitcoincli = os.path.join(
246-
config["environment"]["BUILDDIR"],
247-
"src",
248-
"bitcoin-cli" + config["environment"]["EXEEXT"],
249-
)
250-
fname_bitcoinutil = os.path.join(
251-
config["environment"]["BUILDDIR"],
252-
"src",
253-
"bitcoin-util" + config["environment"]["EXEEXT"],
254-
)
255-
self.options.bitcoind = os.getenv("BITCOIND", default=fname_bitcoind)
256-
self.options.bitcoincli = os.getenv("BITCOINCLI", default=fname_bitcoincli)
257-
self.options.bitcoinutil = os.getenv("BITCOINUTIL", default=fname_bitcoinutil)
257+
self.set_binary_paths()
258258

259259
os.environ['PATH'] = os.pathsep.join([
260260
os.path.join(config['environment']['BUILDDIR'], 'src'),

test/functional/tool_wallet.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@ def skip_test_if_missing_module(self):
3232
self.skip_if_no_wallet_tool()
3333

3434
def bitcoin_wallet_process(self, *args):
35-
binary = self.config["environment"]["BUILDDIR"] + '/src/bitcoin-wallet' + self.config["environment"]["EXEEXT"]
3635
default_args = ['-datadir={}'.format(self.nodes[0].datadir), '-chain=%s' % self.chain]
3736
if not self.options.descriptors and 'create' in args:
3837
default_args.append('-legacy')
3938

40-
return subprocess.Popen([binary] + default_args + list(args), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
39+
return subprocess.Popen([self.options.bitcoinwallet] + default_args + list(args), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
4140

4241
def assert_raises_tool_error(self, error, *args):
4342
p = self.bitcoin_wallet_process(*args)

0 commit comments

Comments
 (0)