Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ii-cruz committed Nov 8, 2024
1 parent ace44ad commit e04db33
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions consensus/tests/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ async fn try_to_induce_request_missing_blocks_on_next_batch() {
}
assert_eq!(syncer.live_sync.queue().num_buffered_blocks(), 1);

// Send block on next batch again.
// Send block on next batch again, nothing should be done since the block is already buffered.
block_tx
.send((block_next_batch.clone(), mock_id.clone()))
.await
Expand All @@ -372,15 +372,16 @@ async fn try_to_induce_request_missing_blocks_on_next_batch() {
assert_eq!(syncer.live_sync.queue().num_buffered_blocks() as u64, 1);
// Let old missing blocks request be processed.
// The reply will result in the blocks being discarded since they have been applied through the block stream.
_ = poll!(mock_node.next());
mock_node.next().await;
syncer.next().await;
assert_eq!(syncer.live_sync.queue().num_buffered_blocks() as u64, 1);

// Send block on the next batch. It is already buffered but now a missing blocks request should be sent.
block_tx
.send((block_next_batch2.clone(), mock_id.clone()))
.await
.unwrap();
let _ = poll!(syncer.next());
_ = poll!(syncer.next());
yield_now().await;
assert_eq!(
blockchain1.read().block_number(),
Expand All @@ -389,12 +390,12 @@ async fn try_to_induce_request_missing_blocks_on_next_batch() {
assert_eq!(syncer.live_sync.queue().num_buffered_blocks() as u64, 2);

// Allow the last requests missing blocks to finish.
_ = poll!(mock_node.next());
mock_node.next().await;
syncer.next().await;
syncer.next().await; // To push the buffered block 1
assert_eq!(blockchain1.read().head_hash(), block_next_batch.hash());
assert_eq!(syncer.live_sync.queue().num_buffered_blocks() as u64, 1);
syncer.next().await; // To push the buffered block 2
syncer.next().await;
_ = poll!(syncer.next()); // To push the buffered block 2
assert_eq!(blockchain1.read().head_hash(), block_next_batch2.hash());
assert_eq!(syncer.live_sync.queue().num_buffered_blocks() as u64, 0);
}
Expand Down Expand Up @@ -511,7 +512,7 @@ async fn try_to_induce_request_missing_blocks_gaps() {
// Let first missing blocks request be processed.
// The reply will result in the blocks for the first request to be discarded
// since they have been applied through the block stream.
_ = poll!(mock_node.next());
mock_node.next().await;
syncer.next().await;

// Assert that the second missing blocks request is still pending.
Expand All @@ -522,7 +523,7 @@ async fn try_to_induce_request_missing_blocks_gaps() {
assert_eq!(syncer.live_sync.queue().num_buffered_blocks() as u64, 1);

// Allow the last requests missing blocks to finish.
_ = poll!(mock_node.next());
mock_node.next().await;
syncer.next().await;
syncer.next().await; // To push the buffered block

Expand Down

0 comments on commit e04db33

Please sign in to comment.