From 69cbbaf4836e1837565f91c82262eb9d6f545c0f Mon Sep 17 00:00:00 2001 From: behzad nouri Date: Thu, 26 May 2022 18:58:06 +0000 Subject: [PATCH] patches flaky gossip pull from entrypoint test (#25589) test_pull_from_entrypoint_if_not_present relies on a deterministic ordering for the entries when generating gossip pull requests. https://github.com/solana-labs/solana/pull/25460 changed an intermediate type for gossip pull-requests from Vec to HashMap, and so the entries are no longer deterministically ordered. This causes the test to be flaky. The commit updates the test so that it no longer relies on the ordering. --- gossip/src/cluster_info.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gossip/src/cluster_info.rs b/gossip/src/cluster_info.rs index 4c7ececef9..8e07ab3875 100644 --- a/gossip/src/cluster_info.rs +++ b/gossip/src/cluster_info.rs @@ -4083,15 +4083,15 @@ mod tests { let (pings, pulls) = cluster_info.new_pull_requests(&thread_pool, None, &stakes); assert!(pings.is_empty()); assert_eq!(pulls.len(), 2 * MIN_NUM_BLOOM_FILTERS); - assert!(pulls - .iter() - .take(MIN_NUM_BLOOM_FILTERS) - .all(|(addr, _)| *addr == other_node.gossip)); - assert!(pulls - .iter() - .skip(MIN_NUM_BLOOM_FILTERS) - .all(|(addr, _)| *addr == entrypoint.gossip)); - + for node in [&other_node, &entrypoint] { + assert_eq!( + pulls + .iter() + .filter(|(addr, _)| *addr == node.gossip) + .count(), + MIN_NUM_BLOOM_FILTERS + ); + } // Pull request 3: `other_node` is present and `entrypoint` was just pulled from. There should // only be one pull request to `other_node` let (pings, pulls) = cluster_info.new_pull_requests(&thread_pool, None, &stakes);