@@ -2711,3 +2711,35 @@ async fn test_declare_and_deploy_in_separate_blocks() {
27112711 compiled_class_hash. 0
27122712 ) ;
27132713}
2714+
2715+ /// Test the behavior of an empty multi-block.
2716+ /// We test the case n_blocks_in_multi_block = `STORED_BLOCK_HASH_BUFFER` to additionally verify
2717+ /// that the last block in the multi-block contains the block-hash of the first block in this case.
2718+ #[ rstest]
2719+ #[ tokio:: test]
2720+ async fn test_empty_multi_block ( ) {
2721+ let ( mut test_manager, _) =
2722+ TestManager :: < DictStateReader > :: new_with_default_initial_state ( [ ] ) . await ;
2723+ let next_block_number = test_manager. initial_state . next_block_number . 0 ;
2724+ assert ! ( next_block_number > STORED_BLOCK_HASH_BUFFER ) ;
2725+
2726+ // Create empty blocks.
2727+ let n_blocks = STORED_BLOCK_HASH_BUFFER + 1 ;
2728+ for _ in 0 ..n_blocks - 1 {
2729+ test_manager. move_to_next_block ( ) ;
2730+ }
2731+
2732+ // Run the test and verify the storage changes.
2733+ let test_output =
2734+ test_manager. execute_test_with_default_block_contexts ( & TestParameters :: default ( ) ) . await ;
2735+ test_output. perform_default_validations ( ) ;
2736+ test_output. assert_storage_diff_eq (
2737+ Const :: BlockHashContractAddress . fetch_from_os_program ( ) . unwrap ( ) . try_into ( ) . unwrap ( ) ,
2738+ HashMap :: from_iter ( ( 0 ..n_blocks) . map ( |block_index| {
2739+ let ( old_block_number, old_block_hash) =
2740+ maybe_dummy_block_hash_and_number ( BlockNumber ( block_index + next_block_number) )
2741+ . unwrap ( ) ;
2742+ ( Felt :: from ( old_block_number. 0 ) , old_block_hash. 0 )
2743+ } ) ) ,
2744+ ) ;
2745+ }
0 commit comments