fix(net): fix flaky test_trusted_peer_only test (#22213)

Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Georgios Konstantopoulos
2026-02-15 19:30:37 -08:00
committed by GitHub
parent 0dd47af250
commit f5cf90227b

View File

@@ -12,7 +12,7 @@ use reth_network::{
};
use reth_network_api::{
events::{PeerEvent, SessionInfo},
NetworkInfo, Peers, PeersInfo,
NetworkInfo, PeerKind, Peers, PeersInfo,
};
use reth_network_p2p::{
headers::client::{HeadersClient, HeadersRequest},
@@ -423,6 +423,11 @@ async fn test_trusted_peer_only() {
tokio::time::sleep(Duration::from_secs(1)).await;
assert_eq!(handle.num_connected_peers(), 1);
// remove handle from handle1's peer list to prevent a competing outgoing connection attempt
// from handle1 racing with handle's outgoing connection below, which can cause duplicate
// session resolution to drop a connection
handle1.remove_peer(*handle.peer_id(), PeerKind::Basic);
handle.add_trusted_peer(*handle1.peer_id(), handle1.local_addr());
// wait for the next session established event to check the handle1 incoming connection