From d718f1d922e56109992205600d3df068ae0a6a8e Mon Sep 17 00:00:00 2001 From: teor Date: Mon, 7 Mar 2022 22:44:03 +1000 Subject: [PATCH] fix(zebrad/test): stop excessive logging which causes test hangs (#3755) * fix(zebrad/test): stop excessive logging which causes test hangs If we print a line every time the network upgrade heights are accessed, some tests hang. This could happen because they are expecting different log output, or because the standard output pipes fill up, blocking the `zebrad` subprocess. * doc(test/nu): explain cargo feature unification and test env vars --- zebra-chain/src/parameters/network_upgrade.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/zebra-chain/src/parameters/network_upgrade.rs b/zebra-chain/src/parameters/network_upgrade.rs index f766c7bf9..bf3452f07 100644 --- a/zebra-chain/src/parameters/network_upgrade.rs +++ b/zebra-chain/src/parameters/network_upgrade.rs @@ -187,20 +187,23 @@ impl NetworkUpgrade { /// and it's a test build, this returns a list of fake activation heights /// used by some tests. pub(crate) fn activation_list(network: Network) -> BTreeMap { - println!( - "activation_list called {:?}", - std::env::var_os("TEST_FAKE_ACTIVATION_HEIGHTS") - ); let (mainnet_heights, testnet_heights) = { #[cfg(not(feature = "zebra-test"))] { (MAINNET_ACTIVATION_HEIGHTS, TESTNET_ACTIVATION_HEIGHTS) } + // To prevent accidentally setting this somehow, only check the env var // when being compiled for tests. We can't use cfg(test) since the // test that uses this is in zebra-state, and cfg(test) is not // set for dependencies. However, zebra-state does set the // zebra-test feature of zebra-chain if it's a dev dependency. + // + // Cargo features are additive, so all test binaries built along with + // zebra-state will have this feature enabled. But we are using + // Rust Edition 2021 and Cargo resolver version 2, so the "zebra-test" + // feature should only be enabled for tests: + // https://doc.rust-lang.org/cargo/reference/features.html#resolver-version-2-command-line-flags #[cfg(feature = "zebra-test")] if std::env::var_os("TEST_FAKE_ACTIVATION_HEIGHTS").is_some() { (