Skip to content

Commit

Permalink
fix(tests): minor test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoga07 committed Jun 6, 2021
1 parent 30814cb commit 7d8b464
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
**/*.rs.bk
Cargo.lock
*.*~
.idea
18 changes: 11 additions & 7 deletions src/connections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ pub(super) fn listen_for_incoming_connections(
);
}
Err(err) => {
error!("An incoming connection failed because of an error: {}", err);
error!(
"An incoming connection failed because of an error: {:?}",
err
);
}
},
None => {
Expand Down Expand Up @@ -216,7 +219,7 @@ async fn read_on_uni_streams(
}
Err(err) => {
warn!(
"Failed to read incoming message on uni-stream for peer {:?} with error: {}",
"Failed to read incoming message on uni-stream for peer {:?} with error: {:?}",
peer_addr, err
);
break;
Expand All @@ -230,7 +233,7 @@ async fn read_on_uni_streams(
Err(Error::StreamRead(quinn::ReadExactError::FinishedEarly)) => break,
Err(err) => {
error!(
"Failed reading from a uni-stream for peer {:?} with error: {}",
"Failed reading from a uni-stream for peer {:?} with error: {:?}",
peer_addr, err
);
break;
Expand All @@ -256,7 +259,7 @@ async fn read_on_bi_streams(
}
Err(err) => {
warn!(
"Failed to read incoming message on bi-stream for peer {:?} with error: {}",
"Failed to read incoming message on bi-stream for peer {:?} with error: {:?}",
peer_addr, err
);
break;
Expand All @@ -269,7 +272,7 @@ async fn read_on_bi_streams(
Ok(WireMsg::EndpointEchoReq) => {
if let Err(error) = handle_endpoint_echo_req(peer_addr, &mut send).await {
error!(
"Failed to handle Echo Request for peer {:?} with error: {}",
"Failed to handle Echo Request for peer {:?} with error: {:?}",
peer_addr, error
);
}
Expand All @@ -283,7 +286,7 @@ async fn read_on_bi_streams(
)
.await
{
error!("Failed to handle Endpoint verification request for peer {:?} with error: {}", peer_addr, error);
error!("Failed to handle Endpoint verification request for peer {:?} with error: {:?}", peer_addr, error);
}
}
Ok(msg) => {
Expand All @@ -295,7 +298,7 @@ async fn read_on_bi_streams(
Err(Error::StreamRead(quinn::ReadExactError::FinishedEarly)) => break,
Err(err) => {
error!(
"Failed reading from a bi-stream for peer {:?} with error: {}",
"Failed reading from a bi-stream for peer {:?} with error: {:?}",
peer_addr, err
);
break;
Expand Down Expand Up @@ -388,6 +391,7 @@ mod tests {

let connection = peer1
.get_connection(&peer2_addr)
.await
.ok_or(Error::MissingConnection)?;
let (mut send_stream, mut recv_stream) = connection.open_bi().await?;
let message = WireMsg::EndpointEchoReq;
Expand Down
4 changes: 2 additions & 2 deletions src/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ async fn disconnection() -> Result<()> {
}

// After Alice disconnects from Bob both peers should receive the disconnected event.
alice.disconnect_from(&bob_addr)?;
alice.disconnect_from(&bob_addr).await?;

if let Some(disconnected_peer) = alice_disconnections.next().await {
assert_eq!(disconnected_peer, bob_addr);
Expand Down Expand Up @@ -273,7 +273,7 @@ async fn simultaneous_incoming_and_outgoing_connections() -> Result<()> {
}

// Drop the connection initiated by Bob.
bob.disconnect_from(&alice_addr)?;
bob.disconnect_from(&alice_addr).await?;

// It should be closed on Alice's side too.
if let Some(disconnected_peer) = alice_disconnections.next().await {
Expand Down

0 comments on commit 7d8b464

Please sign in to comment.