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 4430a48ef3.

* 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 <teor@riseup.net>
This commit is contained in:
Janito Vaqueiro Ferreira Filho 2021-10-31 22:36:08 -03:00 committed by GitHub
parent 6905c79fd6
commit e9d2ba835e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 2 deletions

View File

@ -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();