Skip to content

Commit

Permalink
add failing test to connmanager
Browse files Browse the repository at this point in the history
  • Loading branch information
Frando committed May 22, 2024
1 parent 278d1e6 commit ad018a6
Show file tree
Hide file tree
Showing 4 changed files with 252 additions and 84 deletions.
21 changes: 7 additions & 14 deletions iroh-gossip/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,7 @@ impl Actor {
}
Some(new_conn) = self.conn_manager.next() => {
trace!(?i, "tick: conn_manager");
let node_id = new_conn.node_id;
if let Err(err) = self.handle_new_connection(new_conn).await {
warn!(peer=%node_id.fmt_short(), ?err, "failed to handle new connection");
self.conn_manager.remove(&node_id);
self.conn_send_tx.remove(&node_id);
}
self.handle_new_connection(new_conn).await;
}
Some(res) = self.conn_tasks.join_next(), if !self.conn_tasks.is_empty() => {
match res {
Expand Down Expand Up @@ -435,11 +430,11 @@ impl Actor {
async fn handle_to_actor_msg(&mut self, msg: ToActor, now: Instant) -> anyhow::Result<()> {
trace!("handle to_actor {msg:?}");
match msg {
ToActor::AcceptConn(conn) => {
if let Err(err) = self.conn_manager.push_accept(conn) {
warn!(?err, "failed to accept connection");
}
}
ToActor::AcceptConn(conn) => match self.conn_manager.accept(conn) {
Err(err) => warn!(?err, "failed to accept connection"),
Ok(None) => {}
Ok(Some(conn)) => self.handle_new_connection(conn).await,
},
ToActor::Join(topic_id, peers, reply) => {
self.handle_in_event(InEvent::Command(topic_id, Command::Join(peers)), now)
.await?;
Expand Down Expand Up @@ -550,7 +545,7 @@ impl Actor {
Ok(())
}

async fn handle_new_connection(&mut self, new_conn: NewConnection) -> anyhow::Result<()> {
async fn handle_new_connection(&mut self, new_conn: NewConnection) {
let NewConnection {
conn,
node_id: peer_id,
Expand Down Expand Up @@ -582,8 +577,6 @@ impl Actor {
warn!(peer=%peer_id.fmt_short(), "connecting to node failed: {err:?}");
}
}

Ok(())
}

fn subscribe_all(&mut self) -> broadcast::Receiver<(TopicId, Event)> {
Expand Down
3 changes: 2 additions & 1 deletion iroh-net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ rand = "0.8"
rand_core = "0.6.4"
rcgen = "0.11"
reqwest = { version = "0.11.19", default-features = false, features = ["rustls-tls"] }
rand_chacha = { version = "0.3.1", optional = true }
ring = "0.17"
rustls = { version = "0.21.11", default-features = false, features = ["dangerous_configuration"] }
serde = { version = "1", features = ["derive", "rc"] }
Expand Down Expand Up @@ -124,7 +125,7 @@ duct = "0.13.6"
default = ["metrics"]
iroh-relay = ["clap", "toml", "rustls-pemfile", "regex", "serde_with", "tracing-subscriber"]
metrics = ["iroh-metrics/metrics"]
test-utils = ["axum"]
test-utils = ["axum", "rand_chacha"]

[[bin]]
name = "iroh-relay"
Expand Down

0 comments on commit ad018a6

Please sign in to comment.