Skip to content

Commit 9eb3030

Browse files
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.
1 parent 3c5940a commit 9eb3030

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

protocols/relay/tests/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,16 @@ fn connect() {
210210
src.dial(dst_addr).unwrap();
211211

212212
pool.run_until(futures::future::join(
213-
connection_established_to(src, relay_peer_id, dst_peer_id),
214-
connection_established_to(dst, relay_peer_id, src_peer_id),
213+
connection_established_to(&mut src, relay_peer_id, dst_peer_id),
214+
connection_established_to(&mut dst, relay_peer_id, src_peer_id),
215215
));
216216
}
217217

218-
async fn connection_established_to(mut swarm: Swarm<Client>, relay_peer_id: PeerId, other: PeerId) {
218+
async fn connection_established_to(
219+
swarm: &mut Swarm<Client>,
220+
relay_peer_id: PeerId,
221+
other: PeerId,
222+
) {
219223
loop {
220224
match swarm.select_next_some().await {
221225
SwarmEvent::Dialing(peer_id) if peer_id == relay_peer_id => {}

0 commit comments

Comments
 (0)