Skip to content

Commit

Permalink
Merge #88: avoid setting {BITCOIND,ELEMENTSD}_EXE in setup
Browse files Browse the repository at this point in the history
fb73306 avoid setting {BITCOIND,ELEMENTSD}_EXE in setup (Riccardo Casatta)

Pull request description:

  The logic of setting the env var inside the setup prevents user of other OS like nixos to run the tests (because the included binary are not working on nixos) and also to run other specific versions.
  Setting those env vars is meant to be done in the dev environment not in the code, so this remove the setting of the env vars in the code.
  With this users with `bitcoind` and `elementsd` in their PATH will work too.
  The CI script will set the variables with the included binary only if they are not already set. This allows the CI to run while allowing other users to override with specific versions and run it locally.

  Note this is different from what has been done upstream rust-bitcoin/rust-miniscript#538 but I think it's better

ACKs for top commit:
  apoelstra:
    ACK fb73306; the integration tests work for me in Nix; though after fully enabling my local CI there are a bunch of clippy and other issues everywhere :)

Tree-SHA512: 766a50733db49abb21697733a061d0dfa3ff16f1dfc7562ac943c21d9ffea9924110ec723b390133e3057205612aaa2d0104de80b0fd1c68a6b0581010668668
  • Loading branch information
apoelstra committed Aug 9, 2024
2 parents 1918c57 + fb73306 commit 090ce14
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 0 additions & 8 deletions bitcoind-tests/tests/setup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ pub mod test_util;
// We are not using pegins right now, but it might be required in case in future
// if we extend the tests to check pegins etc.
pub fn setup(validate_pegin: bool) -> (ElementsD, Option<BitcoinD>, elements::BlockHash) {
// Lookup bitcoind binary path
let curr_dir = std::env::current_dir().unwrap();
let bitcoind_path = curr_dir.join("bin/bitcoind");
let elementsd_path = curr_dir.join("bin/elementsd");

std::env::set_var("BITCOIND_EXE", bitcoind_path);
std::env::set_var("ELEMENTSD_EXE", elementsd_path);

let mut bitcoind = None;
if validate_pegin {
let bitcoind_exe = bitcoind::exe_path().unwrap();
Expand Down
7 changes: 7 additions & 0 deletions contrib/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ fi

# Test bitcoind integration tests if told to (this only works with the stable toolchain)
if [ "$DO_BITCOIND_TESTS" = true ]; then

BITCOIND_EXE_DEFAULT="$(git rev-parse --show-toplevel)/bitcoind-tests/bin/bitcoind"
ELEMENTSD_EXE_DEFAULT="$(git rev-parse --show-toplevel)/bitcoind-tests/bin/elementsd"

cd bitcoind-tests

BITCOIND_EXE=${BITCOIND_EXE:=${BITCOIND_EXE_DEFAULT}} \
ELEMENTSD_EXE=${ELEMENTSD_EXE:=${ELEMENTSD_EXE_DEFAULT}} \
cargo test --verbose

# Exit integration tests, do not run other tests.
Expand Down

0 comments on commit 090ce14

Please sign in to comment.