aboutsummaryrefslogtreecommitdiff
path: root/test/functional/test_framework
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2023-05-05 13:35:06 +0100
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2023-05-05 13:35:06 +0100
commitdda961cec5fef318c0b043a09367d14daa87f089 (patch)
tree30877fd6ebea0345ad8d39fe2faf20cc6295a589 /test/functional/test_framework
parentda9f62f912294de07a595df0b4898aba4be6b69c (diff)
test, refactor: Add `set_binary_paths` function
This change factors out the repeated code into a new `set_binary_paths` function.
Diffstat (limited to 'test/functional/test_framework')
-rwxr-xr-xtest/functional/test_framework/test_framework.py35
1 files changed, 17 insertions, 18 deletions
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index 66a23b443c..46a5cfa70c 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -228,6 +228,22 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
PortSeed.n = self.options.port_seed
+ def set_binary_paths(self):
+ """Update self.options with the paths of all binaries from environment variables or their default values"""
+
+ binaries = {
+ "bitcoind": ("bitcoind", "BITCOIND"),
+ "bitcoin-cli": ("bitcoincli", "BITCOINCLI"),
+ "bitcoin-util": ("bitcoinutil", "BITCOINUTIL"),
+ }
+ for binary, [attribute_name, env_variable_name] in binaries.items():
+ default_filename = os.path.join(
+ self.config["environment"]["BUILDDIR"],
+ "src",
+ binary + self.config["environment"]["EXEEXT"],
+ )
+ setattr(self.options, attribute_name, os.getenv(env_variable_name, default=default_filename))
+
def setup(self):
"""Call this method to start up the test framework object with options set."""
@@ -237,24 +253,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
config = self.config
- fname_bitcoind = os.path.join(
- config["environment"]["BUILDDIR"],
- "src",
- "bitcoind" + config["environment"]["EXEEXT"],
- )
- fname_bitcoincli = os.path.join(
- config["environment"]["BUILDDIR"],
- "src",
- "bitcoin-cli" + config["environment"]["EXEEXT"],
- )
- fname_bitcoinutil = os.path.join(
- config["environment"]["BUILDDIR"],
- "src",
- "bitcoin-util" + config["environment"]["EXEEXT"],
- )
- self.options.bitcoind = os.getenv("BITCOIND", default=fname_bitcoind)
- self.options.bitcoincli = os.getenv("BITCOINCLI", default=fname_bitcoincli)
- self.options.bitcoinutil = os.getenv("BITCOINUTIL", default=fname_bitcoinutil)
+ self.set_binary_paths()
os.environ['PATH'] = os.pathsep.join([
os.path.join(config['environment']['BUILDDIR'], 'src'),