Skip to content

Commit ad018a6

Browse files
committed
add failing test to connmanager
1 parent 278d1e6 commit ad018a6

File tree

4 files changed

+252
-84
lines changed

4 files changed

+252
-84
lines changed

iroh-gossip/src/net.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -384,12 +384,7 @@ impl Actor {
384384
}
385385
Some(new_conn) = self.conn_manager.next() => {
386386
trace!(?i, "tick: conn_manager");
387-
let node_id = new_conn.node_id;
388-
if let Err(err) = self.handle_new_connection(new_conn).await {
389-
warn!(peer=%node_id.fmt_short(), ?err, "failed to handle new connection");
390-
self.conn_manager.remove(&node_id);
391-
self.conn_send_tx.remove(&node_id);
392-
}
387+
self.handle_new_connection(new_conn).await;
393388
}
394389
Some(res) = self.conn_tasks.join_next(), if !self.conn_tasks.is_empty() => {
395390
match res {
@@ -435,11 +430,11 @@ impl Actor {
435430
async fn handle_to_actor_msg(&mut self, msg: ToActor, now: Instant) -> anyhow::Result<()> {
436431
trace!("handle to_actor {msg:?}");
437432
match msg {
438-
ToActor::AcceptConn(conn) => {
439-
if let Err(err) = self.conn_manager.push_accept(conn) {
440-
warn!(?err, "failed to accept connection");
441-
}
442-
}
433+
ToActor::AcceptConn(conn) => match self.conn_manager.accept(conn) {
434+
Err(err) => warn!(?err, "failed to accept connection"),
435+
Ok(None) => {}
436+
Ok(Some(conn)) => self.handle_new_connection(conn).await,
437+
},
443438
ToActor::Join(topic_id, peers, reply) => {
444439
self.handle_in_event(InEvent::Command(topic_id, Command::Join(peers)), now)
445440
.await?;
@@ -550,7 +545,7 @@ impl Actor {
550545
Ok(())
551546
}
552547

553-
async fn handle_new_connection(&mut self, new_conn: NewConnection) -> anyhow::Result<()> {
548+
async fn handle_new_connection(&mut self, new_conn: NewConnection) {
554549
let NewConnection {
555550
conn,
556551
node_id: peer_id,
@@ -582,8 +577,6 @@ impl Actor {
582577
warn!(peer=%peer_id.fmt_short(), "connecting to node failed: {err:?}");
583578
}
584579
}
585-
586-
Ok(())
587580
}
588581

589582
fn subscribe_all(&mut self) -> broadcast::Receiver<(TopicId, Event)> {

iroh-net/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ rand = "0.8"
5555
rand_core = "0.6.4"
5656
rcgen = "0.11"
5757
reqwest = { version = "0.11.19", default-features = false, features = ["rustls-tls"] }
58+
rand_chacha = { version = "0.3.1", optional = true }
5859
ring = "0.17"
5960
rustls = { version = "0.21.11", default-features = false, features = ["dangerous_configuration"] }
6061
serde = { version = "1", features = ["derive", "rc"] }
@@ -124,7 +125,7 @@ duct = "0.13.6"
124125
default = ["metrics"]
125126
iroh-relay = ["clap", "toml", "rustls-pemfile", "regex", "serde_with", "tracing-subscriber"]
126127
metrics = ["iroh-metrics/metrics"]
127-
test-utils = ["axum"]
128+
test-utils = ["axum", "rand_chacha"]
128129

129130
[[bin]]
130131
name = "iroh-relay"

0 commit comments

Comments
 (0)