From e9d2ba835ec40de89370a188f7ebc9801769b8e0 Mon Sep 17 00:00:00 2001 From: Janito Vaqueiro Ferreira Filho Date: Sun, 31 Oct 2021 22:36:08 -0300 Subject: [PATCH] Increase maximum request delay for `inbound` tests (#2977) * Avoid spurious test failures on busy machines * Revert "Avoid spurious test failures on busy machines" This reverts commit 4430a48ef3d20ceddf737a2f2741638875b0148c. * Increase request delay for mock network service This is necessary because some tests were having timeouts when running on macOS for the CI. This meant that it took longer than expected for the subject under test to end up sending the network request. Co-authored-by: teor --- zebrad/src/components/inbound/tests.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/zebrad/src/components/inbound/tests.rs b/zebrad/src/components/inbound/tests.rs index d0b064e76..904c30462 100644 --- a/zebrad/src/components/inbound/tests.rs +++ b/zebrad/src/components/inbound/tests.rs @@ -1,6 +1,9 @@ //! Inbound service tests. -use std::{collections::HashSet, iter::FromIterator, net::SocketAddr, str::FromStr, sync::Arc}; +use std::{ + collections::HashSet, iter::FromIterator, net::SocketAddr, str::FromStr, sync::Arc, + time::Duration, +}; use futures::FutureExt; use tokio::{sync::oneshot, task::JoinHandle}; @@ -27,6 +30,14 @@ use crate::{ BoxError, }; +/// Maximum time to wait for a network service request. +/// +/// The default [`MockService`] value can be too short for some of these tests that take a little +/// longer than expected to actually send the network request. +/// +/// Increasing this value causes the tests to take longer to complete, so it can't be too large. +const MAX_PEER_SET_REQUEST_DELAY: Duration = Duration::from_millis(500); + #[tokio::test] async fn mempool_requests_for_transactions() { let ( @@ -581,7 +592,9 @@ async fn setup( zebra_consensus::chain::init(consensus_config.clone(), network, state_service.clone()) .await; - let mut peer_set = MockService::build().for_unit_tests(); + let mut peer_set = MockService::build() + .with_max_request_delay(MAX_PEER_SET_REQUEST_DELAY) + .for_unit_tests(); let buffered_peer_set = Buffer::new(BoxService::new(peer_set.clone()), 10); let mock_tx_verifier = MockService::build().for_unit_tests();