From 0dbbdb5e6ea9b7778ce36c64fe16bf49e1c839a8 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Fri, 3 Jan 2025 18:27:40 +0100 Subject: [PATCH] fixup --- iroh-relay/src/server.rs | 28 ++++++---------------------- iroh-relay/src/server/http_server.rs | 1 - 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/iroh-relay/src/server.rs b/iroh-relay/src/server.rs index 7d0acb7f27..03cda8ade7 100644 --- a/iroh-relay/src/server.rs +++ b/iroh-relay/src/server.rs @@ -1178,30 +1178,14 @@ mod tests { // set up client a let resolver = crate::dns::default_resolver().clone(); - let (client_a, mut client_a_receiver) = - ClientBuilder::new(relay_url.clone()).build(a_secret_key, resolver); - let connect_client = client_a.clone(); - - // give the relay server some time to accept connections - if let Err(err) = tokio::time::timeout(Duration::from_secs(10), async move { - loop { - match connect_client.connect().await { - Ok(_) => break, - Err(err) => { - warn!("client unable to connect to relay server: {err:#}"); - tokio::time::sleep(Duration::from_millis(100)).await; - } - } - } - }) - .await - { - panic!("timeout connecting to relay server: {err:#}"); - } + let mut client_a = ClientBuilder::new(relay_url.clone(), a_secret_key, resolver) + .connect() + .await + .unwrap(); - // wait for a moment, until the connection is shutdown + // the next message should be the rejection of the connection tokio::time::timeout(Duration::from_millis(500), async move { - match client_a_receiver.recv().await.unwrap().unwrap() { + match client_a.next().await.unwrap().unwrap() { ReceivedMessage::Health { problem } => { assert_eq!(problem, Some("not authenticated".to_string())); } diff --git a/iroh-relay/src/server/http_server.rs b/iroh-relay/src/server/http_server.rs index 9b1ecb532c..c19bec653d 100644 --- a/iroh-relay/src/server/http_server.rs +++ b/iroh-relay/src/server/http_server.rs @@ -26,7 +26,6 @@ use tokio_util::{codec::Framed, sync::CancellationToken, task::AbortOnDropHandle use tracing::{debug, debug_span, error, info, info_span, trace, warn, Instrument}; use super::{clients::Clients, AccessConfig}; - use crate::{ defaults::{timeouts::SERVER_WRITE_TIMEOUT, DEFAULT_KEY_CACHE_CAPACITY}, http::{Protocol, LEGACY_RELAY_PATH, RELAY_PATH, SUPPORTED_WEBSOCKET_VERSION},