fix(relay): ensure stable connect test

With the changes from #3767, we made the `connect` test flaky because the `Swarm` was fully passed to the future and thus dropped as soon as the connection was established. We pass a mutable reference instead which keeps the `Swarm` alive.

Pull-Request: #3780.
This commit is contained in:
Thomas Eizinger
2023-04-12 14:04:01 +02:00
committed by GitHub
parent 3c5940aead
commit 9eb3030b1f

View File

@ -210,12 +210,16 @@ fn connect() {
src.dial(dst_addr).unwrap();
pool.run_until(futures::future::join(
connection_established_to(src, relay_peer_id, dst_peer_id),
connection_established_to(dst, relay_peer_id, src_peer_id),
connection_established_to(&mut src, relay_peer_id, dst_peer_id),
connection_established_to(&mut dst, relay_peer_id, src_peer_id),
));
}
async fn connection_established_to(mut swarm: Swarm<Client>, relay_peer_id: PeerId, other: PeerId) {
async fn connection_established_to(
swarm: &mut Swarm<Client>,
relay_peer_id: PeerId,
other: PeerId,
) {
loop {
match swarm.select_next_some().await {
SwarmEvent::Dialing(peer_id) if peer_id == relay_peer_id => {}