Skip to content

Commit

Permalink
address some review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alindima committed Jan 10, 2024
1 parent 51d68e7 commit e34d874
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion substrate/client/network/src/request_responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ impl NetworkBehaviour for RequestResponsesBehaviour {
if let Some((fallback_request, fallback_protocol)) =
fallback_request
{
log::debug!(
log::trace!(
target: "sub-libp2p",
"Request with id {:?} failed. Trying the fallback protocol. {}",
request_id,
Expand Down Expand Up @@ -1061,6 +1061,7 @@ mod tests {
use super::*;

use crate::mock::MockPeerStore;
use assert_matches::assert_matches;
use futures::{channel::oneshot, executor::LocalPool, task::Spawn};
use libp2p::{
core::{
Expand Down Expand Up @@ -1664,6 +1665,29 @@ mod tests {
protocol_name_1_fallback.clone()
)
);
// Try the new protocol with no fallback. Should fail.
let (sender, response_receiver) = oneshot::channel();
swarm.behaviour_mut().send_request(
older_peer_id.as_ref().unwrap(),
protocol_name_1.clone(),
b"request on protocol /test/req-resp-2".to_vec(),
None,
sender,
IfDisconnected::ImmediateError,
);
loop {
match swarm.select_next_some().await {
SwarmEvent::Behaviour(Event::RequestFinished { result, .. }) => {
assert_matches!(
result.unwrap_err(),
RequestFailure::Network(OutboundFailure::UnsupportedProtocols)
);
break
},
_ => {},
}
}
assert!(response_receiver.await.unwrap().is_err());
// Try the other protocol with no fallback.
let (sender, response_receiver) = oneshot::channel();
swarm.behaviour_mut().send_request(
Expand Down

0 comments on commit e34d874

Please sign in to comment.