Skip to content

Commit

Permalink
fix(zebrad/test): stop excessive logging which causes test hangs (#3755)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
teor2345 authored Mar 7, 2022
1 parent 3342589 commit d718f1d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions zebra-chain/src/parameters/network_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<block::Height, NetworkUpgrade> {
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() {
(
Expand Down

0 comments on commit d718f1d

Please sign in to comment.