@@ -5573,28 +5573,30 @@ pub(crate) mod tests {
55735573
55745574 #[ test]
55755575 fn missing_body_gap_is_removed_for_non_archive_node ( ) {
5576- // Create a non-archive backend and produce a MissingBody gap.
5576+ // Create a non-archive backend and produce a multi-block MissingBody gap.
55775577 let backend = Backend :: < Block > :: new_test_with_tx_storage ( BlocksPruning :: Some ( 100 ) , 0 ) ;
55785578 assert ! ( !backend. is_archive) ;
55795579
55805580 let genesis_hash = insert_header ( & backend, 0 , Default :: default ( ) , None , Default :: default ( ) ) ;
55815581
5582- // Insert block 1 without body — creates a MissingBody gap at block 1.
5583- insert_header_no_body_as_best ( & backend, 1 , genesis_hash) ;
5582+ // Insert blocks 1..3 without bodies — creates a MissingBody gap spanning blocks 1 to 3.
5583+ let hash_1 = insert_header_no_body_as_best ( & backend, 1 , genesis_hash) ;
5584+ let hash_2 = insert_header_no_body_as_best ( & backend, 2 , hash_1) ;
5585+ insert_header_no_body_as_best ( & backend, 3 , hash_2) ;
55845586
55855587 let info = backend. blockchain ( ) . info ( ) ;
55865588 assert ! ( info. block_gap. is_some( ) , "MissingBody gap should have been created" ) ;
55875589 let gap = info. block_gap . unwrap ( ) ;
55885590 assert ! ( matches!( gap. gap_type, BlockGapType :: MissingBody ) ) ;
55895591 assert_eq ! ( gap. start, 1 ) ;
5590- assert_eq ! ( gap. end, 1 ) ;
5592+ assert_eq ! ( gap. end, 3 ) ;
55915593
55925594 // Re-open the same database as a non-archive node.
55935595 let db = backend. storage . db . clone ( ) ;
55945596 let backend = reopen_backend ( db, BlocksPruning :: Some ( 100 ) ) ;
55955597 assert ! ( !backend. is_archive) ;
55965598
5597- // The gap should have been removed on re-open.
5599+ // The multi-block gap should have been removed on re-open.
55985600 let info = backend. blockchain ( ) . info ( ) ;
55995601 assert ! (
56005602 info. block_gap. is_none( ) ,
@@ -5605,19 +5607,23 @@ pub(crate) mod tests {
56055607
56065608 #[ test]
56075609 fn missing_body_gap_is_preserved_for_archive_node ( ) {
5608- // Create a backend with archive pruning and produce a MissingBody gap.
5610+ // Create a backend with archive pruning and produce a multi-block MissingBody gap.
56095611 let backend = Backend :: < Block > :: new_test_with_tx_storage ( BlocksPruning :: KeepAll , 0 ) ;
56105612 assert ! ( backend. is_archive) ;
56115613
56125614 let genesis_hash = insert_header ( & backend, 0 , Default :: default ( ) , None , Default :: default ( ) ) ;
56135615
5614- // Insert block 1 without body — creates a MissingBody gap at block 1.
5615- insert_header_no_body_as_best ( & backend, 1 , genesis_hash) ;
5616+ // Insert blocks 1..3 without bodies — creates a MissingBody gap spanning blocks 1 to 3.
5617+ let hash_1 = insert_header_no_body_as_best ( & backend, 1 , genesis_hash) ;
5618+ let hash_2 = insert_header_no_body_as_best ( & backend, 2 , hash_1) ;
5619+ insert_header_no_body_as_best ( & backend, 3 , hash_2) ;
56165620
56175621 let info = backend. blockchain ( ) . info ( ) ;
56185622 assert ! ( info. block_gap. is_some( ) , "MissingBody gap should have been created" ) ;
56195623 let gap = info. block_gap . unwrap ( ) ;
56205624 assert ! ( matches!( gap. gap_type, BlockGapType :: MissingBody ) ) ;
5625+ assert_eq ! ( gap. start, 1 ) ;
5626+ assert_eq ! ( gap. end, 3 ) ;
56215627
56225628 // Re-open the same database as an archive node.
56235629 let db = backend. storage . db . clone ( ) ;
@@ -5630,7 +5636,7 @@ pub(crate) mod tests {
56305636 let gap = info. block_gap . unwrap ( ) ;
56315637 assert ! ( matches!( gap. gap_type, BlockGapType :: MissingBody ) ) ;
56325638 assert_eq ! ( gap. start, 1 ) ;
5633- assert_eq ! ( gap. end, 1 ) ;
5639+ assert_eq ! ( gap. end, 3 ) ;
56345640 }
56355641
56365642 #[ test]
0 commit comments