mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-13 01:51:23 +00:00
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:
@ -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 => {}
|
||||
|
Reference in New Issue
Block a user