Skip to content

Fix: flaky net::tests::convergence tests #6046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion stackslib/src/net/tests/convergence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn stacker_db_id(i: usize) -> QualifiedContractIdentifier {

fn make_stacker_db_ids(i: usize) -> Vec<QualifiedContractIdentifier> {
let mut dbs = vec![];
for j in 0..i {
for j in 0..i + 1 {
dbs.push(stacker_db_id(j));
}
dbs
Expand Down Expand Up @@ -1053,6 +1053,45 @@ fn run_topology_test_ex<F>(
(100.0 * (peer_counts as f64)) / ((peer_count * peer_count) as f64),
);

// wait for stacker DBs to converge
for (i, peer) in peers.iter().enumerate() {
if i % 2 != 0 {
continue;
}
for (j, other_peer) in peers.iter().enumerate() {
if i == j {
continue;
}

let all_neighbors =
PeerDB::get_all_peers(other_peer.network.peerdb.conn()).unwrap();

if (all_neighbors.len() as u64) < ((peer_count - 1) as u64) {
// this is a simulated-NAT'ed node -- it won't learn about other NAT'ed nodes'
// DBs
continue;
}

if j % 2 != 0 {
continue; // this peer doesn't support Stacker DBs
}
let dbs = peer
.network
.peerdb
.get_peer_stacker_dbs(&other_peer.config.to_neighbor())
.unwrap();
if dbs.is_empty() {
test_debug!(
"waiting for peer {i} {} to learn about peer {j} {}'s stacker DBs",
&peer.config.to_neighbor(),
&other_peer.config.to_neighbor()
);
finished = false;
break;
}
}
}

if finished {
break;
}
Expand Down