refactor(client): Introduce and apply test helper for timeout servers

This commit is contained in:
Nils Andreas Svee committed 2026-05-10 20:56:43 +07:00
1 parent 80bdb7d84a
commit f095eb5930
1 file changed
+8 -6
+8 -6
View File
@@ -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)