mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-26 16:21:39 +00:00
@ -55,7 +55,7 @@ where
|
||||
{
|
||||
InboundUpgradeApply {
|
||||
inner: InboundUpgradeApplyState::Init {
|
||||
future: multistream_select::listener_select_proto(conn, up.protocol_info().into_iter()),
|
||||
future: multistream_select::listener_select_proto(conn, up.protocol_info()),
|
||||
upgrade: up,
|
||||
},
|
||||
}
|
||||
|
@ -354,9 +354,16 @@ mod tests {
|
||||
.block_peer(*listener.local_peer_id());
|
||||
|
||||
let (
|
||||
[SwarmEvent::ConnectionClosed { peer_id: closed_dialer_peer, .. }],
|
||||
[SwarmEvent::ConnectionClosed { peer_id: closed_listener_peer, .. }]
|
||||
) = libp2p_swarm_test::drive(&mut dialer, &mut listener).await else {
|
||||
[SwarmEvent::ConnectionClosed {
|
||||
peer_id: closed_dialer_peer,
|
||||
..
|
||||
}],
|
||||
[SwarmEvent::ConnectionClosed {
|
||||
peer_id: closed_listener_peer,
|
||||
..
|
||||
}],
|
||||
) = libp2p_swarm_test::drive(&mut dialer, &mut listener).await
|
||||
else {
|
||||
panic!("unexpected events")
|
||||
};
|
||||
assert_eq!(closed_dialer_peer, *listener.local_peer_id());
|
||||
@ -417,9 +424,22 @@ mod tests {
|
||||
.unwrap();
|
||||
|
||||
let (
|
||||
[SwarmEvent::OutgoingConnectionError { error: DialError::Denied { cause: outgoing_cause }, .. }],
|
||||
[_, SwarmEvent::IncomingConnectionError { error: ListenError::Denied { cause: incoming_cause }, .. }],
|
||||
) = libp2p_swarm_test::drive(&mut dialer, &mut listener).await else {
|
||||
[SwarmEvent::OutgoingConnectionError {
|
||||
error:
|
||||
DialError::Denied {
|
||||
cause: outgoing_cause,
|
||||
},
|
||||
..
|
||||
}],
|
||||
[_, SwarmEvent::IncomingConnectionError {
|
||||
error:
|
||||
ListenError::Denied {
|
||||
cause: incoming_cause,
|
||||
},
|
||||
..
|
||||
}],
|
||||
) = libp2p_swarm_test::drive(&mut dialer, &mut listener).await
|
||||
else {
|
||||
panic!("unexpected events")
|
||||
};
|
||||
assert!(outgoing_cause.downcast::<NotAllowed>().is_ok());
|
||||
@ -447,9 +467,16 @@ mod tests {
|
||||
.list
|
||||
.disallow_peer(*listener.local_peer_id());
|
||||
let (
|
||||
[SwarmEvent::ConnectionClosed { peer_id: closed_dialer_peer, .. }],
|
||||
[SwarmEvent::ConnectionClosed { peer_id: closed_listener_peer, .. }]
|
||||
) = libp2p_swarm_test::drive(&mut dialer, &mut listener).await else {
|
||||
[SwarmEvent::ConnectionClosed {
|
||||
peer_id: closed_dialer_peer,
|
||||
..
|
||||
}],
|
||||
[SwarmEvent::ConnectionClosed {
|
||||
peer_id: closed_listener_peer,
|
||||
..
|
||||
}],
|
||||
) = libp2p_swarm_test::drive(&mut dialer, &mut listener).await
|
||||
else {
|
||||
panic!("unexpected events")
|
||||
};
|
||||
assert_eq!(closed_dialer_peer, *listener.local_peer_id());
|
||||
|
@ -411,7 +411,7 @@ mod tests {
|
||||
assert!(len < (1 << 15));
|
||||
let frame = (0..len).map(|n| (n & 0xff) as u8).collect::<Vec<_>>();
|
||||
let mut data = vec![(len & 0x7f) as u8 | 0x80, (len >> 7) as u8];
|
||||
data.extend(frame.clone().into_iter());
|
||||
data.extend(frame.clone());
|
||||
let mut framed = LengthDelimited::new(Cursor::new(data));
|
||||
let recved = futures::executor::block_on(async move { framed.next().await }).unwrap();
|
||||
assert_eq!(recved.unwrap(), frame);
|
||||
|
@ -47,8 +47,7 @@ fn select_proto_basic() {
|
||||
|
||||
let client = async_std::task::spawn(async move {
|
||||
let protos = vec!["/proto3", "/proto2"];
|
||||
let (proto, mut io) =
|
||||
dialer_select_proto(client_connection, protos.into_iter(), version)
|
||||
let (proto, mut io) = dialer_select_proto(client_connection, protos, version)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(proto, "/proto2");
|
||||
@ -99,12 +98,8 @@ fn negotiation_failed() {
|
||||
}
|
||||
});
|
||||
|
||||
let client =
|
||||
async_std::task::spawn(async move {
|
||||
let mut io =
|
||||
match dialer_select_proto(client_connection, dial_protos.into_iter(), version)
|
||||
.await
|
||||
{
|
||||
let client = async_std::task::spawn(async move {
|
||||
let mut io = match dialer_select_proto(client_connection, dial_protos, version).await {
|
||||
Err(NegotiationError::Failed) => return,
|
||||
Ok((_, io)) => io,
|
||||
Err(_) => panic!(),
|
||||
@ -185,8 +180,7 @@ async fn v1_lazy_do_not_wait_for_negotiation_on_poll_close() {
|
||||
let client = async_std::task::spawn(async move {
|
||||
// Single protocol to allow for lazy (or optimistic) protocol negotiation.
|
||||
let protos = vec!["/proto1"];
|
||||
let (proto, mut io) =
|
||||
dialer_select_proto(client_connection, protos.into_iter(), Version::V1Lazy)
|
||||
let (proto, mut io) = dialer_select_proto(client_connection, protos, Version::V1Lazy)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(proto, "/proto1");
|
||||
|
@ -858,7 +858,7 @@ fn test_handle_received_subscriptions() {
|
||||
// UNSUBSCRIBE - Remove topic from peer_topics for peer.
|
||||
// - Remove peer from topic_peers.
|
||||
|
||||
let topics = vec!["topic1", "topic2", "topic3", "topic4"]
|
||||
let topics = ["topic1", "topic2", "topic3", "topic4"]
|
||||
.iter()
|
||||
.map(|&t| String::from(t))
|
||||
.collect();
|
||||
@ -1280,7 +1280,7 @@ fn test_handle_graft_is_not_subscribed() {
|
||||
#[test]
|
||||
// tests multiple topics in a single graft message
|
||||
fn test_handle_graft_multiple_topics() {
|
||||
let topics: Vec<String> = vec!["topic1", "topic2", "topic3", "topic4"]
|
||||
let topics: Vec<String> = ["topic1", "topic2", "topic3", "topic4"]
|
||||
.iter()
|
||||
.map(|&t| String::from(t))
|
||||
.collect();
|
||||
|
@ -222,7 +222,7 @@ mod test {
|
||||
let t1 = TopicHash::from_raw("t1");
|
||||
let t2 = TopicHash::from_raw("t2");
|
||||
|
||||
let old = BTreeSet::from_iter(vec![t1.clone()].into_iter());
|
||||
let old = BTreeSet::from_iter(vec![t1.clone()]);
|
||||
let subscriptions = vec![
|
||||
Subscription {
|
||||
action: Unsubscribe,
|
||||
|
@ -40,7 +40,8 @@ fn webtransport_server_empty_certhashes() {
|
||||
|
||||
// Invalid case, because a MITM attacker may strip certificates of the server.
|
||||
let Err(noise::Error::UnknownWebTransportCerthashes(expected, received)) =
|
||||
handshake_with_certhashes(vec![certhash1, certhash2], vec![]) else {
|
||||
handshake_with_certhashes(vec![certhash1, certhash2], vec![])
|
||||
else {
|
||||
panic!("unexpected result");
|
||||
};
|
||||
|
||||
@ -68,7 +69,8 @@ fn webtransport_server_uninit_certhashes() {
|
||||
|
||||
// Invalid case, because a MITM attacker may strip certificates of the server.
|
||||
let Err(noise::Error::UnknownWebTransportCerthashes(expected, received)) =
|
||||
handshake_with_certhashes(vec![certhash1, certhash2], None) else {
|
||||
handshake_with_certhashes(vec![certhash1, certhash2], None)
|
||||
else {
|
||||
panic!("unexpected result");
|
||||
};
|
||||
|
||||
@ -81,7 +83,8 @@ fn webtransport_different_server_certhashes() {
|
||||
let (certhash1, certhash2, certhash3) = certhashes();
|
||||
|
||||
let Err(noise::Error::UnknownWebTransportCerthashes(expected, received)) =
|
||||
handshake_with_certhashes(vec![certhash1, certhash3], vec![certhash1, certhash2]) else {
|
||||
handshake_with_certhashes(vec![certhash1, certhash3], vec![certhash1, certhash2])
|
||||
else {
|
||||
panic!("unexpected result");
|
||||
};
|
||||
|
||||
@ -94,7 +97,8 @@ fn webtransport_superset_of_certhashes() {
|
||||
let (certhash1, certhash2, _) = certhashes();
|
||||
|
||||
let Err(noise::Error::UnknownWebTransportCerthashes(expected, received)) =
|
||||
handshake_with_certhashes(vec![certhash1, certhash2], vec![certhash1]) else {
|
||||
handshake_with_certhashes(vec![certhash1, certhash2], vec![certhash1])
|
||||
else {
|
||||
panic!("unexpected result");
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user