Skip to content

Commit dc5f5af

Browse files
authored
Fix flaky test_rpc_block_reprocessing (#7595)
The test occasionally fails, likely because the 10ms fixed delay after block processing isn't insufficient when the system is under load. #7522 (comment) Replace single assertion with retry loop.
1 parent ccd99c1 commit dc5f5af

File tree

1 file changed

+19
-5
lines changed
  • beacon_node/network/src/network_beacon_processor

1 file changed

+19
-5
lines changed

beacon_node/network/src/network_beacon_processor/tests.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,11 +1252,25 @@ async fn test_rpc_block_reprocessing() {
12521252
tokio::time::sleep(QUEUED_RPC_BLOCK_DELAY).await;
12531253

12541254
rig.assert_event_journal(&[WorkType::RpcBlock.into()]).await;
1255-
// Add an extra delay for block processing
1256-
tokio::time::sleep(Duration::from_millis(10)).await;
1257-
// head should update to next block now since the duplicate
1258-
// cache handle was dropped.
1259-
assert_eq!(next_block_root, rig.head_root());
1255+
1256+
let max_retries = 3;
1257+
let mut success = false;
1258+
for _ in 0..max_retries {
1259+
// Add an extra delay for block processing
1260+
tokio::time::sleep(Duration::from_millis(10)).await;
1261+
// head should update to the next block now since the duplicate
1262+
// cache handle was dropped.
1263+
if next_block_root == rig.head_root() {
1264+
success = true;
1265+
break;
1266+
}
1267+
}
1268+
assert!(
1269+
success,
1270+
"expected head_root to be {:?} but was {:?}",
1271+
next_block_root,
1272+
rig.head_root()
1273+
);
12601274
}
12611275

12621276
/// Ensure that backfill batches get rate-limited and processing is scheduled at specified intervals.

0 commit comments

Comments
 (0)