aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authoropen-trade <[email protected]>2020-04-24 18:15:41 +0800
committeropen-trade <[email protected]>2020-04-24 18:15:41 +0800
commit6ae81878492f4b28093add88782eb18cf3d8bbdb (patch)
tree5faa0cdc571d3afa37128fa06118c55eda10dd2e /src
parent9feb083a37b1b607fb07c3a25f4f8a49c1afab33 (diff)
downloadrustdesk-server-6ae81878492f4b28093add88782eb18cf3d8bbdb.tar.gz
rustdesk-server-6ae81878492f4b28093add88782eb18cf3d8bbdb.zip
remove broken test
Diffstat (limited to 'src')
-rw-r--r--src/rendezvous_server.rs90
1 files changed, 1 insertions, 89 deletions
diff --git a/src/rendezvous_server.rs b/src/rendezvous_server.rs
index e75f993..922c427 100644
--- a/src/rendezvous_server.rs
+++ b/src/rendezvous_server.rs
@@ -132,92 +132,4 @@ impl RendezvousServer {
}
Ok(())
}
-}
-
-#[cfg(test)]
-mod tests {
- use super::*;
- use hbb_common::tokio;
-
- #[allow(unused_must_use)]
- #[tokio::main]
- async fn test_rs_async() {
- let mut port_server: u16 = 0;
- let socket = FramedSocket::new("127.0.0.1:0").await.unwrap();
- if let SocketAddr::V4(addr) = socket.get_ref().local_addr().unwrap() {
- port_server = addr.port();
- }
- drop(socket);
- let addr_server = format!("127.0.0.1:{}", port_server);
- let f1 = RendezvousServer::start(&addr_server);
- let addr_server = addr_server.parse().unwrap();
- let f2 = punch_hole(addr_server);
- tokio::try_join!(f1, f2);
- }
-
- async fn punch_hole(addr_server: SocketAddr) -> ResultType<()> {
- // B register it to server
- let mut socket_b = FramedSocket::new("127.0.0.1:0").await?;
- let local_addr_b = socket_b.get_ref().local_addr().unwrap();
- let mut msg_out = RendezvousMessage::new();
- msg_out.set_register_peer(RegisterPeer {
- id: "123".to_string(),
- ..Default::default()
- });
- socket_b.send(&msg_out, addr_server).await?;
-
- // A send punch request to server
- let mut socket_a = FramedSocket::new("127.0.0.1:0").await?;
- let local_addr_a = socket_a.get_ref().local_addr().unwrap();
- msg_out.set_punch_hole_request(PunchHoleRequest {
- id: "123".to_string(),
- ..Default::default()
- });
- socket_a.send(&msg_out, addr_server).await?;
-
- println!(
- "A {:?} request punch hole to B {:?} via server {:?}",
- local_addr_a, local_addr_b, addr_server,
- );
-
- // on B side, responsed to A's punch request forwarded from server
- if let Some(Ok((bytes, addr))) = socket_b.next_timeout(1000).await {
- assert_eq!(addr_server, addr);
- let msg_in = parse_from_bytes::<RendezvousMessage>(&bytes)?;
- let remote_addr_a = AddrMangle::decode(&msg_in.get_punch_hole().socket_addr);
- assert_eq!(local_addr_a, remote_addr_a);
-
- // B punch A
- socket_b
- .get_mut()
- .send_to(&b"SYN"[..], &remote_addr_a)
- .await?;
-
- msg_out.set_punch_hole_sent(PunchHoleSent {
- socket_addr: AddrMangle::encode(&remote_addr_a),
- ..Default::default()
- });
- socket_b.send(&msg_out, addr_server).await?;
- } else {
- panic!("failed");
- }
-
- // on A side
- socket_a.next().await; // skip "SYN"
- if let Some(Ok((bytes, addr))) = socket_a.next_timeout(1000).await {
- assert_eq!(addr_server, addr);
- let msg_in = parse_from_bytes::<RendezvousMessage>(&bytes)?;
- let remote_addr_b = AddrMangle::decode(&msg_in.get_punch_hole_response().socket_addr);
- assert_eq!(local_addr_b, remote_addr_b);
- } else {
- panic!("failed");
- }
-
- Err("done".into())
- }
-
- #[test]
- fn test_rs() {
- self::test_rs_async();
- }
-}
+} \ No newline at end of file