Remove non-determinism from zrpc::tests::peer::test_io_error

This commit is contained in:
Antonio Scandurra 2021-09-23 15:55:28 +02:00
parent a1ca507498
commit c70b4a99c9

View file

@ -520,8 +520,7 @@ mod tests {
#[test] #[test]
fn test_io_error() { fn test_io_error() {
smol::block_on(async move { smol::block_on(async move {
let (client_conn, server_conn, _) = Connection::in_memory(); let (client_conn, mut server_conn, _) = Connection::in_memory();
drop(server_conn);
let client = Peer::new(); let client = Peer::new();
let (connection_id, io_handler, mut incoming) = let (connection_id, io_handler, mut incoming) =
@ -529,11 +528,14 @@ mod tests {
smol::spawn(io_handler).detach(); smol::spawn(io_handler).detach();
smol::spawn(async move { incoming.next().await }).detach(); smol::spawn(async move { incoming.next().await }).detach();
let err = client let response = smol::spawn(client.request(connection_id, proto::Ping {}));
.request(connection_id, proto::Ping {}) let _request = server_conn.rx.next().await.unwrap().unwrap();
.await
.unwrap_err(); drop(server_conn);
assert_eq!(err.to_string(), "connection was closed"); assert_eq!(
response.await.unwrap_err().to_string(),
"connection was closed"
);
}); });
} }
} }