@@ -945,14 +945,12 @@ async fn test_listener_restart_and_chain_reorg() -> Result<(), anyhow::Error> {
945945 test_listener_no_event_loss ( true , true ) . await
946946}
947947
948- async fn check_finalization_status (
949- setup : Setup
950- ) {
948+ async fn check_finalization_status ( setup : Setup ) {
951949 let provider = ProviderBuilder :: new ( )
952- . wallet ( setup. wallets [ 0 ] . clone ( ) )
953- . connect_ws ( WsConnect :: new ( setup. args . url . to_string ( ) ) )
954- . await
955- . unwrap ( ) ;
950+ . wallet ( setup. wallets [ 0 ] . clone ( ) )
951+ . connect_ws ( WsConnect :: new ( setup. args . url . to_string ( ) ) )
952+ . await
953+ . unwrap ( ) ;
956954 // Verify block finalization status: for each block number, one should be finalized and others orphaned
957955 let blocks = sqlx:: query!(
958956 "SELECT block_number, block_hash, block_status FROM host_chain_blocks_valid"
@@ -962,7 +960,10 @@ async fn check_finalization_status(
962960
963961 let blocks = blocks. expect ( "Failed to fetch blocks from database" ) ;
964962
965- let mut blocks_by_number: std:: collections:: HashMap < i64 , Vec < ( Vec < u8 > , String ) > > = std:: collections:: HashMap :: new ( ) ;
963+ let mut blocks_by_number: std:: collections:: HashMap <
964+ i64 ,
965+ Vec < ( Vec < u8 > , String ) > ,
966+ > = std:: collections:: HashMap :: new ( ) ;
966967 for block in blocks {
967968 blocks_by_number
968969 . entry ( block. block_number )
@@ -971,21 +972,37 @@ async fn check_finalization_status(
971972 }
972973
973974 for ( block_number, block_variants) in blocks_by_number. iter ( ) {
974- let finalized_count = block_variants. iter ( ) . filter ( |( _, status) | status == "finalized" ) . count ( ) ;
975- let orphan_count = block_variants. iter ( ) . filter ( |( _, status) | status == "orphaned" ) . count ( ) ;
975+ let finalized_count = block_variants
976+ . iter ( )
977+ . filter ( |( _, status) | status == "finalized" )
978+ . count ( ) ;
979+ let orphan_count = block_variants
980+ . iter ( )
981+ . filter ( |( _, status) | status == "orphaned" )
982+ . count ( ) ;
976983 assert_eq ! (
977984 finalized_count, 1 ,
978985 "Block {} should have exactly one finalized variant, found {}" ,
979986 block_number, finalized_count
980987 ) ;
981- let finalized_hash = block_variants. iter ( ) . find ( |( _, status) | status == "finalized" ) . map ( |( hash, _) | hash) . unwrap ( ) ;
988+ let finalized_hash = block_variants
989+ . iter ( )
990+ . find ( |( _, status) | status == "finalized" )
991+ . map ( |( hash, _) | hash)
992+ . unwrap ( ) ;
982993 assert_eq ! (
983994 orphan_count,
984995 block_variants. len( ) - 1 ,
985996 "Block {} should have remaining variants as orphan" ,
986997 block_number
987998 ) ;
988- let expected_hash= provider. get_block_by_number ( ( * block_number as u64 ) . into ( ) ) . await . unwrap ( ) . unwrap ( ) . header . hash ;
999+ let expected_hash = provider
1000+ . get_block_by_number ( ( * block_number as u64 ) . into ( ) )
1001+ . await
1002+ . unwrap ( )
1003+ . unwrap ( )
1004+ . header
1005+ . hash ;
9891006 assert_eq ! (
9901007 & expected_hash. 0 ,
9911008 finalized_hash. as_slice( ) ,
0 commit comments