From 64cd225dca402a9c08fb0a53490579d5593cdc6c Mon Sep 17 00:00:00 2001 From: Lin Oshitani Date: Wed, 22 Mar 2023 07:04:57 +0900 Subject: [PATCH] fix(gossipsub): fix check for fanout peer inclusion in test_join The check for fanout peer inclusion in `test_join` does not check anything since `new_peers` is always empty. https://github.com/libp2p/rust-libp2p/blob/12b785e94ede1e763dd041a107d3a00d5135a213/protocols/gossipsub/src/behaviour/tests.rs#L611 I assume the intention was to fill the `new_peers` with the fanout peers. In this MR I do just that. Pull-Request: #3628. --- protocols/gossipsub/src/behaviour/tests.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/protocols/gossipsub/src/behaviour/tests.rs b/protocols/gossipsub/src/behaviour/tests.rs index ab1deb32..b3734525 100644 --- a/protocols/gossipsub/src/behaviour/tests.rs +++ b/protocols/gossipsub/src/behaviour/tests.rs @@ -580,7 +580,7 @@ fn test_join() { // add 3 random peers to the fanout[topic1] gs.fanout .insert(topic_hashes[1].clone(), Default::default()); - let new_peers: Vec = vec![]; + let mut new_peers: Vec = vec![]; for _ in 0..3 { let random_peer = PeerId::random(); // inform the behaviour of a new peer @@ -598,6 +598,7 @@ fn test_join() { // add the new peer to the fanout let fanout_peers = gs.fanout.get_mut(&topic_hashes[1]).unwrap(); fanout_peers.insert(random_peer); + new_peers.push(random_peer); } // subscribe to topic1