From f095eb59304f14667f18204c4e36426424e6f034 Mon Sep 17 00:00:00 2001 From: Nils Andreas Svee Date: Tue, 28 Apr 2026 16:42:06 +0700 Subject: [PATCH] refactor(client): Introduce and apply test helper for timeout servers --- crates/irtt-client/src/client.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/irtt-client/src/client.rs b/crates/irtt-client/src/client.rs index b72592d..ebc8db0 100644 --- a/crates/irtt-client/src/client.rs +++ b/crates/irtt-client/src/client.rs @@ -311,6 +311,13 @@ mod tests { }) } + fn timeout_server(wait: Duration) -> FakeServer { + start_fake_server(move |socket, tx| { + socket.set_read_timeout(Some(wait)).unwrap(); + while recv_request_timeout(&socket, &tx).is_some() {} + }) + } + fn assert_open_started(outcome: OpenOutcome) -> NegotiatedParams { match outcome { OpenOutcome::Started { @@ -455,12 +462,7 @@ mod tests { #[test] fn open_timeout_after_all_timeouts() { - let server = start_fake_server(|socket, tx| { - socket - .set_read_timeout(Some(Duration::from_millis(700))) - .unwrap(); - while recv_request_timeout(&socket, &tx).is_some() {} - }); + let server = timeout_server(Duration::from_millis(700)); let config = ClientConfig { open_timeouts: vec![Duration::from_millis(200), Duration::from_millis(200)], ..default_test_config(server.addr)