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