diff --git a/zebra-network/src/peer_set/unready_service.rs b/zebra-network/src/peer_set/unready_service.rs index 97fc8d7e0..108a9e830 100644 --- a/zebra-network/src/peer_set/unready_service.rs +++ b/zebra-network/src/peer_set/unready_service.rs @@ -1,5 +1,6 @@ -// Adapted from tower-balance - +/// Services that are busy or newly created. +/// +/// Adapted from tower-balance. use std::{ future::Future, marker::PhantomData, @@ -21,11 +22,18 @@ mod tests; #[pin_project] #[derive(Debug)] pub(super) struct UnreadyService { + /// The key used to lookup `service`. pub(super) key: Option, + + /// A oneshot used to cancel the request the `service` is currently working on, if any. #[pin] pub(super) cancel: oneshot::Receiver, + + /// The `service` that is busy (or newly created). pub(super) service: Option, + /// Dropping `service` might drop a request. + /// This [`PhantomData`] tells the Rust compiler to do a drop check for `Req`. pub(super) _req: PhantomData, } diff --git a/zebra-network/src/protocol/external/tests/preallocate.rs b/zebra-network/src/protocol/external/tests/preallocate.rs index 25ca76e5f..3875e8a5a 100644 --- a/zebra-network/src/protocol/external/tests/preallocate.rs +++ b/zebra-network/src/protocol/external/tests/preallocate.rs @@ -1,6 +1,6 @@ //! Tests for trusted preallocation during deserialization. -use std::convert::TryInto; +use std::env; use proptest::prelude::*; @@ -20,7 +20,16 @@ use crate::{ }, }; +/// The number of test cases to use for expensive proptests. +const DEFAULT_PROPTEST_CASES: u32 = 8; + proptest! { + // Set the PROPTEST_CASES env var to override this default. + #![proptest_config(proptest::test_runner::Config::with_cases(env::var("PROPTEST_CASES") + .ok() + .and_then(|v| v.parse().ok()) + .unwrap_or(DEFAULT_PROPTEST_CASES)))] + /// Confirm that each InventoryHash takes the expected size in bytes when serialized. #[test] fn inv_hash_size_is_correct(inv in any::()) { @@ -71,6 +80,12 @@ proptest! { } proptest! { + // Set the PROPTEST_CASES env var to override this default. + #![proptest_config(proptest::test_runner::Config::with_cases(env::var("PROPTEST_CASES") + .ok() + .and_then(|v| v.parse().ok()) + .unwrap_or(DEFAULT_PROPTEST_CASES)))] + /// Confirm that each AddrV1 takes exactly ADDR_V1_SIZE bytes when serialized. /// This verifies that our calculated `TrustedPreallocate::max_allocation()` is indeed an upper bound. #[test] @@ -122,6 +137,12 @@ proptest! { } proptest! { + // Set the PROPTEST_CASES env var to override this default. + #![proptest_config(proptest::test_runner::Config::with_cases(env::var("PROPTEST_CASES") + .ok() + .and_then(|v| v.parse().ok()) + .unwrap_or(DEFAULT_PROPTEST_CASES)))] + /// Confirm that each AddrV2 takes at least ADDR_V2_MIN_SIZE bytes when serialized. /// This verifies that our calculated `TrustedPreallocate::max_allocation()` is indeed an upper bound. #[test] diff --git a/zebrad/tests/acceptance.rs b/zebrad/tests/acceptance.rs index c1fd951ce..7e1827e67 100644 --- a/zebrad/tests/acceptance.rs +++ b/zebrad/tests/acceptance.rs @@ -1811,6 +1811,15 @@ async fn delete_old_databases() -> Result<()> { zebra_test::init(); + // Skip this test because it can be very slow without a network. + // + // The delete databases task is launched last during startup, after network setup. + // If there is no network, network setup can take a long time to timeout, + // so the task takes a long time to launch, slowing down this test. + if zebra_test::net::zebra_skip_network_tests() { + return Ok(()); + } + let mut config = default_test_config()?; let run_dir = testdir()?; let cache_dir = run_dir.path().join("state");