Merge bitcoin/bitcoin#32921: test: less ambiguous error if bitcoind is missing

83bb414557 test: less ambiguous error if bitcoind is missing (Sjors Provoost)

Pull request description:

  Before this change, when a functional test is run without building the source,  the error message suggested that previous release binaries were missing.

  When no previous release version is set, make the error message more specifically about bitcoind.

  To test, try this before and after:

  ```sh
  git clean -dfx
  cmake -B build
  build/test/functional/mining_basic.py
  cmake --build build
  build/test/functional/mining_basic.py
  build/test/functional/wallet_backwards_compatibility.py
  test/get_previous_releases.py
  build/test/functional/wallet_backwards_compatibility.py
  ```

ACKs for top commit:
  achow101:
    ACK 83bb414557
  janb84:
    ACK 83bb414557
  w0xlt:
    ACK 83bb414557

Tree-SHA512: c6df65019de99d6c214951cf70944c4ddca9b635c5ab60ac2c47e4589478e9c65d5e079c394ace9b470a7eaeea3c9cf68b7246dd413e802c4a1e071913a7fc32
This commit is contained in:
Ava Chow
2025-07-10 14:51:11 -07:00

View File

@@ -545,18 +545,23 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
extra_args[i] = extra_args[i] + ["-whitelist=noban,in,out@127.0.0.1"] extra_args[i] = extra_args[i] + ["-whitelist=noban,in,out@127.0.0.1"]
if versions is None: if versions is None:
versions = [None] * num_nodes versions = [None] * num_nodes
bin_dirs = [bin_dir_from_version(v) for v in versions] bin_dirs = []
# Fail test if any of the needed release binaries is missing for v in versions:
bins_missing = False bin_dir = bin_dir_from_version(v)
for bin_path in (argv[0] for bin_dir in bin_dirs
for binaries in (self.get_binaries(bin_dir),) # Fail test if any of the needed release binaries is missing
for argv in (binaries.node_argv(), binaries.rpc_argv())): for bin_path in (argv[0] for binaries in (self.get_binaries(bin_dir),)
if shutil.which(bin_path) is None: for argv in (binaries.node_argv(), binaries.rpc_argv())):
self.log.error(f"Binary not found: {bin_path}")
bins_missing = True if shutil.which(bin_path) is None:
if bins_missing: self.log.error(f"Binary not found: {bin_path}")
raise AssertionError("At least one release binary is missing. " if v is None:
"Previous releases binaries can be downloaded via `test/get_previous_releases.py`.") raise AssertionError("At least one binary is missing, did you compile?")
raise AssertionError("At least one release binary is missing. "
"Previous releases binaries can be downloaded via `test/get_previous_releases.py`.")
bin_dirs.append(bin_dir)
assert_equal(len(extra_confs), num_nodes) assert_equal(len(extra_confs), num_nodes)
assert_equal(len(extra_args), num_nodes) assert_equal(len(extra_args), num_nodes)
assert_equal(len(versions), num_nodes) assert_equal(len(versions), num_nodes)