From fb73306e692700a582b121cf80be850d2fc5f5cf Mon Sep 17 00:00:00 2001 From: Riccardo Casatta Date: Thu, 8 Aug 2024 09:46:05 +0200 Subject: [PATCH] avoid setting {BITCOIND,ELEMENTSD}_EXE in setup 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). Setting those env vars is meant to be done in the dev environment not in the code. With this users with `bitcoind` and `elementsd` in their PATH will work too. The CI script will set the variables only if they are not already set. (Allowing Nixos users to override and run it locally) --- bitcoind-tests/tests/setup/mod.rs | 8 -------- contrib/test.sh | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/bitcoind-tests/tests/setup/mod.rs b/bitcoind-tests/tests/setup/mod.rs index 48c77c2b..b443fddd 100644 --- a/bitcoind-tests/tests/setup/mod.rs +++ b/bitcoind-tests/tests/setup/mod.rs @@ -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, 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(); diff --git a/contrib/test.sh b/contrib/test.sh index 71236ce4..b860d570 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -22,7 +22,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.