#[test] fn end_to_end () -> anyhow::Result <()> { let rt = tokio::runtime::Runtime::new ()?; rt.block_on (end_to_end_async ())?; Ok (()) } async fn end_to_end_async () -> anyhow::Result <()> { use crate::executable_end_server as server; use crate::executable_relay_server as relay; let relay_opt = relay::Opt { listen_addr: "127.0.0.1:0".to_string ().into (), tcp_listen_port: None, }; let relay_app = relay::App::new (relay_opt)?; let relay_quic_port = relay_app.listen_addr ().port (); let relay_cert = Vec::from (relay_app.server_cert ()); let task_relay = tokio::spawn (async move { relay_app.run ().await }); // Connect with wrong port, should fail let server_conf = server::Config { debug_echo: false, id: "bogus".into (), relay_addr: "127.0.0.1:80".parse ()?, relay_cert: relay_cert.clone (), use_udp_over_tcp: false, }; let server_err = server::P4EndServer::connect (server_conf).await; assert! (server_err.is_err ()); // Connect with wrong cert, should fail let server_conf = server::Config { debug_echo: false, id: "bogus".into (), relay_addr: ([127, 0, 0, 1], relay_quic_port).into (), relay_cert: vec! [], use_udp_over_tcp: false, }; let server_err = server::P4EndServer::connect (server_conf).await; assert! (server_err.is_err ()); // Connect properly let server_conf = server::Config { debug_echo: false, id: "bogus".into (), relay_addr: ([127, 0, 0, 1], relay_quic_port).into (), relay_cert: relay_cert.clone (), use_udp_over_tcp: false, }; let (server, _) = server::P4EndServer::connect (server_conf).await?; Ok (()) }