Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fallback request for req-response protocols #2771

Merged
merged 11 commits into from Jan 10, 2024
Expand Up @@ -139,6 +139,7 @@ mod tests {
use futures::{executor, future};

use parity_scale_codec::Encode;
use sc_network::ProtocolName;
use sp_core::testing::TaskExecutor;

use polkadot_node_primitives::BlockData;
Expand Down Expand Up @@ -231,7 +232,10 @@ mod tests {
Some(Requests::PoVFetchingV1(outgoing)) => {outgoing}
);
req.pending_response
.send(Ok(PoVFetchingResponse::PoV(pov.clone()).encode()))
.send(Ok((
PoVFetchingResponse::PoV(pov.clone()).encode(),
ProtocolName::from(""),
)))
.unwrap();
break
},
Expand Down
Expand Up @@ -25,7 +25,7 @@ use futures::{
Future, FutureExt, StreamExt,
};

use sc_network as network;
use sc_network::{self as network, ProtocolName};
use sp_keyring::Sr25519Keyring;

use polkadot_node_network_protocol::request_response::{v1, Recipient};
Expand Down Expand Up @@ -252,7 +252,7 @@ impl TestRun {
}
}
req.pending_response
.send(response.map(Encode::encode))
.send(response.map(|r| (r.encode(), ProtocolName::from(""))))
.expect("Sending response should succeed");
}
return (valid_responses == 0) && self.valid_chunks.is_empty()
Expand Down
Expand Up @@ -19,6 +19,7 @@ use std::{
time::Duration,
};

use network::ProtocolName;
use polkadot_node_subsystem_test_helpers::TestSubsystemContextHandle;
use polkadot_node_subsystem_util::TimeoutExt;

Expand Down Expand Up @@ -324,7 +325,11 @@ fn to_incoming_req(
let response = rx.await;
let payload = response.expect("Unexpected canceled request").result;
pending_response
.send(payload.map_err(|_| network::RequestFailure::Refused))
.send(
payload
.map_err(|_| network::RequestFailure::Refused)
.map(|r| (r, ProtocolName::from(""))),
)
.expect("Sending response is expected to work");
}
.boxed(),
Expand Down