Skip to content

Commit

Permalink
refactor(batcher): block builder test, add empty block case
Browse files Browse the repository at this point in the history
  • Loading branch information
Yael-Starkware committed Nov 3, 2024
1 parent 8e556ed commit 18cd8e5
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion crates/batcher/src/block_builder_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ fn two_chunks_test_expectations(
(mock_transaction_executor, mock_tx_provider, expected_block_artifacts)
}

fn empty_block_test_expectations()
-> (MockTransactionExecutorTrait, MockTransactionProvider, BlockExecutionArtifacts) {
let mut mock_transaction_executor = MockTransactionExecutorTrait::new();
mock_transaction_executor.expect_add_txs_to_block().times(0);

let expected_block_artifacts = set_close_block_expectations(&mut mock_transaction_executor, 0);

let mock_tx_provider = mock_tx_provider(1, vec![vec![]]);

(mock_transaction_executor, mock_tx_provider, expected_block_artifacts)
}

// Fill the executor outputs with some non-default values to make sure the block_builder uses
// them.
fn block_builder_expected_output(execution_info_len: usize) -> BlockExecutionArtifacts {
Expand Down Expand Up @@ -169,11 +181,12 @@ async fn run_build_block(
block_builder.build_block(deadline, Box::new(tx_provider), output_sender).await.unwrap()
}

// TODO: Add test cases for block full, empty block, failed transaction,
// TODO: Add test cases for block full, failed transaction,
// timeout reached.
#[rstest]
#[case::one_chunk_block(3, test_txs(0..3), one_chunk_test_expectations(&input_txs))]
#[case::two_chunks_block(6, test_txs(0..6), two_chunks_test_expectations(&input_txs))]
#[case::empty_block(0, vec![], empty_block_test_expectations())]
#[tokio::test]
async fn test_build_block(
#[case] expected_block_size: usize,
Expand Down

0 comments on commit 18cd8e5

Please sign in to comment.