Skip to content
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

patches flaky test_rpc_slot_updates #26593

Merged
merged 1 commit into from
Jul 14, 2022
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
23 changes: 14 additions & 9 deletions rpc-test/tests/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,35 +195,40 @@ fn test_rpc_slot_updates() {

// Verify that updates are received in order for an upcoming slot
let verify_slot = first_update.slot() + 2;
let mut expected_update_index = 0;
let expected_updates = vec![
"CreatedBank",
"Completed",
"Frozen",
"OptimisticConfirmation",
"Root", // TODO: debug why root signal is sent twice.
"Root",
];
let mut expected_updates = expected_updates.into_iter().peekable();
// SlotUpdate::Completed is sent asynchronous to banking-stage and replay
// when shreds are inserted into blockstore. When the leader generates
// blocks, replay may freeze the bank before shreds are all inserted into
// blockstore; and so SlotUpdate::Completed may be received _after_
// SlotUpdate::Frozen.
let mut slot_update_completed = false;

let test_start = Instant::now();
loop {
while expected_updates.peek().is_some() || !slot_update_completed {
assert!(test_start.elapsed() < Duration::from_secs(30));
let update = update_receiver
.recv_timeout(Duration::from_secs(2))
.unwrap();
if update.slot() == verify_slot {
let update_name = match update {
SlotUpdate::CreatedBank { .. } => "CreatedBank",
SlotUpdate::Completed { .. } => "Completed",
SlotUpdate::Completed { .. } => {
slot_update_completed = true;
continue;
}
SlotUpdate::Frozen { .. } => "Frozen",
SlotUpdate::OptimisticConfirmation { .. } => "OptimisticConfirmation",
SlotUpdate::Root { .. } => "Root",
_ => continue,
};
assert_eq!(update_name, expected_updates[expected_update_index]);
expected_update_index += 1;
if expected_update_index == expected_updates.len() {
break;
}
assert_eq!(Some(update_name), expected_updates.next());
}
}
}
Expand Down