From 10604601a09f990f2b6ae5fe57913462bc5f17cc Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Wed, 25 Jan 2023 13:27:37 +1100 Subject: [PATCH 1/2] Construct dummy handler --- protocols/gossipsub/src/behaviour/tests.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/protocols/gossipsub/src/behaviour/tests.rs b/protocols/gossipsub/src/behaviour/tests.rs index f4fd7800b07..e3287aef0cb 100644 --- a/protocols/gossipsub/src/behaviour/tests.rs +++ b/protocols/gossipsub/src/behaviour/tests.rs @@ -265,15 +265,21 @@ where role_override: Endpoint::Dialer, }; // this is not relevant // peer_connections.connections should never be empty. + let mut active_connections = peer_connections.connections.len(); for connection_id in peer_connections.connections.clone() { - let handler = gs.new_handler(); active_connections = active_connections.checked_sub(1).unwrap(); + + let dummy_handler = GossipsubHandler::new( + ProtocolConfig::new(&GossipsubConfig::default()), + Duration::ZERO, + ); + gs.on_swarm_event(FromSwarm::ConnectionClosed(ConnectionClosed { peer_id: *peer_id, connection_id, endpoint: &fake_endpoint, - handler, + handler: dummy_handler, remaining_established: active_connections, })); } From dd952e461f33707bfabf2acccab0ee076e9671f5 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Wed, 25 Jan 2023 13:32:58 +1100 Subject: [PATCH 2/2] Fix ctor arguments --- 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 e3287aef0cb..175ccad4064 100644 --- a/protocols/gossipsub/src/behaviour/tests.rs +++ b/protocols/gossipsub/src/behaviour/tests.rs @@ -33,6 +33,7 @@ use async_std::net::Ipv4Addr; use byteorder::{BigEndian, ByteOrder}; use libp2p_core::{ConnectedPoint, Endpoint}; use rand::Rng; +use std::borrow::Cow; use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; use std::thread::sleep; @@ -271,7 +272,7 @@ where active_connections = active_connections.checked_sub(1).unwrap(); let dummy_handler = GossipsubHandler::new( - ProtocolConfig::new(&GossipsubConfig::default()), + ProtocolConfig::new(Cow::from(""), None, 0, ValidationMode::None, false), Duration::ZERO, );