Skip to content

Commit

Permalink
Delete tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaseizinger committed May 22, 2023
1 parent fc58b54 commit 62ec482
Showing 1 changed file with 0 additions and 105 deletions.
105 changes: 0 additions & 105 deletions protocols/autonat/tests/test_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use libp2p_autonat::{
};
use libp2p_core::{multiaddr::Protocol, ConnectedPoint, Endpoint, Multiaddr};
use libp2p_identity::PeerId;
use libp2p_swarm::DialError;
use libp2p_swarm::{Swarm, SwarmEvent};
use libp2p_swarm_test::SwarmExt as _;
use std::{num::NonZeroU32, time::Duration};
Expand Down Expand Up @@ -127,51 +126,6 @@ async fn test_dial_back() {
}
}

#[async_std::test]
async fn test_dial_error() {
let (mut server, server_id, server_addr) = new_server_swarm(None).await;
let (mut client, client_id) = new_client_swarm(server_id, server_addr).await;
client.add_external_address("/ip4/127.0.0.1/tcp/12345".parse().unwrap());
async_std::task::spawn(client.loop_on_next());

let request_probe_id = match server.next_behaviour_event().await {
Event::InboundProbe(InboundProbeEvent::Request { peer, probe_id, .. }) => {
assert_eq!(peer, client_id);
probe_id
}
other => panic!("Unexpected behaviour event: {other:?}."),
};

loop {
match server.next_swarm_event().await {
SwarmEvent::OutgoingConnectionError { peer_id, error, .. } => {
assert_eq!(peer_id.unwrap(), client_id);
assert!(matches!(error, DialError::Transport(_)));
break;
}
SwarmEvent::Dialing {
peer_id: Some(peer),
..
} => assert_eq!(peer, client_id),
SwarmEvent::NewListenAddr { .. } | SwarmEvent::ExpiredListenAddr { .. } => {}
other => panic!("Unexpected swarm event: {other:?}."),
}
}

match server.next_behaviour_event().await {
Event::InboundProbe(InboundProbeEvent::Error {
probe_id,
peer,
error,
}) => {
assert_eq!(probe_id, request_probe_id);
assert_eq!(peer, client_id);
assert_eq!(error, InboundProbeError::Response(ResponseError::DialError));
}
other => panic!("Unexpected behaviour event: {other:?}."),
}
}

#[async_std::test]
async fn test_throttle_global_max() {
let (mut server, server_id, server_addr) = new_server_swarm(Some(Config {
Expand Down Expand Up @@ -259,65 +213,6 @@ async fn test_throttle_peer_max() {
};
}

#[async_std::test]
async fn test_dial_multiple_addr() {
let (mut server, server_id, server_addr) = new_server_swarm(Some(Config {
throttle_clients_peer_max: 1,
throttle_clients_period: Duration::from_secs(60),
only_global_ips: false,
..Default::default()
}))
.await;

let (mut client, client_id) = new_client_swarm(server_id, server_addr.clone()).await;
client.listen().await;
client.add_external_address("/ip4/127.0.0.1/tcp/12345".parse().unwrap());
async_std::task::spawn(client.loop_on_next());

let dial_addresses = match server.next_behaviour_event().await {
Event::InboundProbe(InboundProbeEvent::Request {
peer, addresses, ..
}) => {
assert_eq!(addresses.len(), 2);
assert_eq!(client_id, peer);
addresses
}
other => panic!("Unexpected behaviour event: {other:?}."),
};

loop {
match server.next_swarm_event().await {
SwarmEvent::ConnectionEstablished {
peer_id,
endpoint:
ConnectedPoint::Dialer {
address,
role_override: Endpoint::Dialer,
},
concurrent_dial_errors,
..
} => {
assert_eq!(peer_id, client_id);
let dial_errors = concurrent_dial_errors.unwrap();

// The concurrent dial might not be fast enough to produce a dial error.
if let Some((addr, _)) = dial_errors.get(0) {
assert_eq!(addr, &dial_addresses[0]);
}

assert_eq!(address, dial_addresses[1]);
break;
}
SwarmEvent::Dialing {
peer_id: Some(peer),
..
} => assert_eq!(peer, client_id),
SwarmEvent::NewListenAddr { .. } | SwarmEvent::ExpiredListenAddr { .. } => {}
other => panic!("Unexpected swarm event: {other:?}."),
}
}
}

#[async_std::test]
async fn test_global_ips_config() {
let (mut server, server_id, server_addr) = new_server_swarm(Some(Config {
Expand Down

0 comments on commit 62ec482

Please sign in to comment.