swarm/src/lib: Improve connection counting for test_behaviour_disconnect_all (#2532)

This commit is contained in:
Max Inden
2022-03-02 12:10:57 +01:00
committed by GitHub
parent a179dbb449
commit b919d0002a
2 changed files with 36 additions and 16 deletions

View File

@ -159,6 +159,18 @@ where
&mut self.inner
}
pub fn num_connections_to_peer(&self, peer: PeerId) -> usize {
self.inject_connection_established
.iter()
.filter(|(peer_id, _, _, _)| *peer_id == peer)
.count()
- self
.inject_connection_closed
.iter()
.filter(|(peer_id, _, _, _)| *peer_id == peer)
.count()
}
/// Checks that when the expected number of closed connection notifications are received, a
/// given number of expected disconnections have been received as well.
///