fix: flaky adding two same ip ephemerals (#177)
* fix: flaky adding two same ip ephemerals * refactor: handle clippy warning * refactor: grammar and simplify counting to or
This commit is contained in:
parent
b49f156745
commit
e7408bad82
@ -251,7 +251,7 @@ mod tests {
|
||||
Swarm::listen_on(&mut swarm1, "/ip4/127.0.0.1/tcp/0".parse().unwrap()).unwrap();
|
||||
|
||||
let peer1 = async move {
|
||||
while let Some(_) = swarm1.next().now_or_never() {}
|
||||
while swarm1.next().now_or_never().is_some() {}
|
||||
|
||||
for l in Swarm::listeners(&swarm1) {
|
||||
tx.send(l.clone()).await.unwrap();
|
||||
|
@ -30,8 +30,22 @@ fn multiple_concurrent_ephemeral_listening_addresses_on_same_ip() {
|
||||
|
||||
let (first, second) = futures::future::join(first, second).await;
|
||||
|
||||
// one should succeed and other should fail
|
||||
assert_eq!(first.is_ok(), second.is_err());
|
||||
// before we have an Swarm-alike api on the background task to make sure the two futures
|
||||
// (first and second) would attempt to modify the background task before a poll to the
|
||||
// inner swarm, this will produce one or two successes.
|
||||
//
|
||||
// with two attempts without polling the swarm in the between:
|
||||
// assert_eq!(first.is_ok(), second.is_err());
|
||||
//
|
||||
// intuitively it could seem that first will always succeed because it must get the first
|
||||
// attempt to push messages into the queue but not sure if that should be leaned on.
|
||||
|
||||
assert!(
|
||||
first.is_ok() || second.is_ok(),
|
||||
"first: {:?}, second: {:?}",
|
||||
first,
|
||||
second
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user