refactor(client): Introduce and apply test helper for timeout servers
This commit is contained in:
1 parent
80bdb7d84a
commit
f095eb5930
1 file changed
+8
-6
@@ -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 {
|
fn assert_open_started(outcome: OpenOutcome) -> NegotiatedParams {
|
||||||
match outcome {
|
match outcome {
|
||||||
OpenOutcome::Started {
|
OpenOutcome::Started {
|
||||||
@@ -455,12 +462,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn open_timeout_after_all_timeouts() {
|
fn open_timeout_after_all_timeouts() {
|
||||||
let server = start_fake_server(|socket, tx| {
|
let server = timeout_server(Duration::from_millis(700));
|
||||||
socket
|
|
||||||
.set_read_timeout(Some(Duration::from_millis(700)))
|
|
||||||
.unwrap();
|
|
||||||
while recv_request_timeout(&socket, &tx).is_some() {}
|
|
||||||
});
|
|
||||||
let config = ClientConfig {
|
let config = ClientConfig {
|
||||||
open_timeouts: vec![Duration::from_millis(200), Duration::from_millis(200)],
|
open_timeouts: vec![Duration::from_millis(200), Duration::from_millis(200)],
|
||||||
..default_test_config(server.addr)
|
..default_test_config(server.addr)
|
||||||
|
|||||||
Reference in new issue
Block a user