From b83d5c483c6996b48c86a5a2f6db93f46deccf8a Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Sat, 2 Sep 2023 14:45:07 -0700 Subject: [PATCH] Test automatic adjustment of max ACK delay --- quinn-proto/src/tests/mod.rs | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/quinn-proto/src/tests/mod.rs b/quinn-proto/src/tests/mod.rs index 7d6639713..74f0b7459 100644 --- a/quinn-proto/src/tests/mod.rs +++ b/quinn-proto/src/tests/mod.rs @@ -2743,6 +2743,50 @@ fn ack_frequency_ack_sent_after_reordered_packets_above_threshold() { ); } +#[test] +fn ack_frequency_update_max_delay() { + let _guard = subscribe(); + let (mut pair, client_ch, server_ch) = setup_ack_frequency_test(Duration::from_millis(200)); + + // Ack frequency was sent initially + assert_eq!( + pair.server_conn_mut(server_ch) + .stats() + .frame_rx + .ack_frequency, + 1 + ); + + // Client sends a PING + info!("first ping"); + pair.client_conn_mut(client_ch).ping(); + pair.drive(); + + // No change in ACK frequency + assert_eq!( + pair.server_conn_mut(server_ch) + .stats() + .frame_rx + .ack_frequency, + 1 + ); + + // RTT jumps, client sends another ping + info!("delayed ping"); + pair.latency *= 10; + pair.client_conn_mut(client_ch).ping(); + pair.drive(); + + // ACK frequency updated + assert!( + pair.server_conn_mut(server_ch) + .stats() + .frame_rx + .ack_frequency + >= 2 + ); +} + fn stream_chunks(mut recv: RecvStream) -> Vec { let mut buf = Vec::new();