Skip to content

Commit

Permalink
fix test initializtion & fn on_connection_established
Browse files Browse the repository at this point in the history
  • Loading branch information
leonzchang committed Oct 17, 2023
1 parent 26257f7 commit dd730da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions protocols/kad/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1884,12 +1884,18 @@ where
ConnectionEstablished {
peer_id,
failed_addresses,
other_established,
..
}: ConnectionEstablished,
) {
for addr in failed_addresses {
self.address_failed(peer_id, addr);
}

// Peer's first connection.
if other_established == 0 {
self.connected_peers.insert(peer_id);
}
}

fn on_address_change(
Expand Down Expand Up @@ -2025,8 +2031,6 @@ where
}) {
handler.on_behaviour_event(event)
}

self.connected_peers.insert(peer);
}
}

Expand Down
3 changes: 2 additions & 1 deletion protocols/kad/src/behaviour/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ fn build_node_with_config(cfg: Config) -> (Multiaddr, TestSwarm) {
transport,
behaviour,
local_id,
swarm::Config::with_async_std_executor(),
swarm::Config::with_async_std_executor()
.with_idle_connection_timeout(Duration::from_secs(60 * 5)),
);

let address: Multiaddr = Protocol::Memory(random::<u64>()).into();
Expand Down

0 comments on commit dd730da

Please sign in to comment.