Skip to content

Commit

Permalink
[consensus][buffer_manager_test] compare all ordered blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ibalajiarun authored and JoshLind committed Jun 20, 2024
1 parent 742b5e5 commit d300088
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions consensus/src/pipeline/tests/buffer_manager_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,23 @@ async fn assert_results(
batches: Vec<Vec<PipelinedBlock>>,
result_rx: &mut Receiver<OrderedBlocks>,
) {
for (i, batch) in enumerate(batches) {
let mut blocks: Vec<PipelinedBlock> = Vec::new();
for _ in 0..batches.len() {
let OrderedBlocks { ordered_blocks, .. } = result_rx.next().await.unwrap();
assert_eq!(
ordered_blocks.last().unwrap().id(),
batch.last().unwrap().id(),
"Inconsistent Block IDs (expected {} got {}) for {}-th block",
batch.last().unwrap().id(),
ordered_blocks.last().unwrap().id(),
i,
);
blocks.extend(ordered_blocks.into_iter());
}

for (i, batch) in enumerate(batches) {
for (idx, ordered_block) in blocks.drain(..batch.len()).enumerate() {
assert_eq!(
ordered_block.id(),
batch[idx].id(),
"Inconsistent Block IDs (expected {} got {}) for {}-th block",
batch[idx].id(),
ordered_block.id(),
i,
);
}
}
}

Expand Down

0 comments on commit d300088

Please sign in to comment.