From 6b795be77fc03bc1453d7d7173d4db6d5d3d4f15 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 30 Jan 2023 16:10:50 +0100 Subject: [PATCH] fix: increase minimum request timeout (#1078) --- crates/net/network/src/session/active.rs | 6 +++--- crates/net/network/tests/it/requests.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/net/network/src/session/active.rs b/crates/net/network/src/session/active.rs index d2b9cc62c7..3207e6f15c 100644 --- a/crates/net/network/src/session/active.rs +++ b/crates/net/network/src/session/active.rs @@ -81,7 +81,7 @@ pub(crate) struct ActiveSession { /// Constants for timeout updating /// Minimum timeout value -const MINIMUM_TIMEOUT: Duration = Duration::from_millis(1); +const MINIMUM_TIMEOUT: Duration = Duration::from_secs(2); /// Maximum timeout value const MAXIMUM_TIMEOUT: Duration = INITIAL_REQUEST_TIMEOUT; /// How much the new measurements affect the current timeout (X percent) @@ -204,7 +204,7 @@ impl ActiveSession { None } - /// Handle an incoming peer request. + /// Handle an internal peer request that will be sent to the remote. fn on_peer_request(&mut self, request: PeerRequest, deadline: Instant) { let request_id = self.next_id(); let msg = request.create_request_message(request_id); @@ -839,7 +839,7 @@ mod tests { #[test] fn timeout_calculation_sanity_tests() { - let rtt = Duration::from_millis(200); + let rtt = Duration::from_secs(5); // timeout for an RTT of `rtt` let timeout = rtt * TIMEOUT_SCALING; diff --git a/crates/net/network/tests/it/requests.rs b/crates/net/network/tests/it/requests.rs index 6db84d0f8f..37dc8f526e 100644 --- a/crates/net/network/tests/it/requests.rs +++ b/crates/net/network/tests/it/requests.rs @@ -113,7 +113,7 @@ async fn test_get_header() { HeadersRequest { start: hash.into(), limit: 1, direction: HeadersDirection::Falling }; let res = fetch0.get_headers(req).await; - assert!(res.is_ok()); + assert!(res.is_ok(), "{res:?}"); let headers = res.unwrap().1 .0; assert_eq!(headers.len(), 1);