@@ -15,7 +15,6 @@ use dash_spv::{
1515} ;
1616use dashcore:: network:: address:: AddrV2Message ;
1717use dashcore:: network:: constants:: ServiceFlags ;
18- use tokio:: sync:: broadcast;
1918use dashcore:: Amount ;
2019use key_wallet:: wallet:: initialization:: WalletAccountCreationOptions ;
2120use key_wallet:: wallet:: managed_wallet_info:: wallet_info_interface:: WalletInfoInterface ;
@@ -28,6 +27,7 @@ use std::path::PathBuf;
2827use std:: sync:: Arc ;
2928use std:: time:: Duration ;
3029use tempfile:: TempDir ;
30+ use tokio:: sync:: broadcast;
3131use tokio:: sync:: mpsc:: UnboundedSender ;
3232use tokio:: sync:: watch;
3333use tokio:: sync:: RwLock ;
@@ -253,7 +253,6 @@ async fn wait_for_sync(
253253 }
254254}
255255
256-
257256/// Count all unique transactions across wallet accounts.
258257async fn count_wallet_transactions (
259258 wallet : & Arc < RwLock < WalletManager < ManagedWalletInfo > > > ,
@@ -536,13 +535,24 @@ async fn test_sync_with_multiple_restarts() {
536535
537536 fn is_restart_event ( event : & SyncEvent ) -> bool {
538537 match event {
539- SyncEvent :: BlockHeadersStored { .. }
540- | SyncEvent :: FilterHeadersStored { .. }
541- | SyncEvent :: FiltersStored { .. }
542- | SyncEvent :: BlocksNeeded { .. } => true ,
538+ SyncEvent :: BlockHeadersStored {
539+ ..
540+ }
541+ | SyncEvent :: FilterHeadersStored {
542+ ..
543+ }
544+ | SyncEvent :: FiltersStored {
545+ ..
546+ }
547+ | SyncEvent :: BlocksNeeded {
548+ ..
549+ } => true ,
543550 // Only count block processing that generated new addresses (gap limit).
544551 // Re-processed blocks from storage with no new info are not real progress.
545- SyncEvent :: BlockProcessed { new_addresses, .. } => !new_addresses. is_empty ( ) ,
552+ SyncEvent :: BlockProcessed {
553+ new_addresses,
554+ ..
555+ } => !new_addresses. is_empty ( ) ,
546556 _ => false ,
547557 }
548558 }
@@ -596,13 +606,8 @@ async fn test_sync_with_multiple_restarts() {
596606 if !should_restart {
597607 // SyncComplete received — verify and finish
598608 let mut client = client_handle. stop ( ) . await ;
599- assert_synced_wallet_matches_expected (
600- & client. progress ( ) ,
601- & wallet,
602- & wallet_id,
603- & ctx,
604- )
605- . await ;
609+ assert_synced_wallet_matches_expected ( & client. progress ( ) , & wallet, & wallet_id, & ctx)
610+ . await ;
606611 tracing:: info!( "Sync completed after {} restarts" , restart_count) ;
607612 client. stop ( ) . await . expect ( "Failed to stop client" ) ;
608613 break ;
@@ -634,8 +639,7 @@ async fn test_sync_with_random_restarts() {
634639 for i in 0 ..num_restarts {
635640 let delay_ms = rng. gen_range ( 50 ..500 ) ;
636641 tracing:: info!( "=== Restart {}: sleeping {}ms before stopping ===" , i + 1 , delay_ms) ;
637- let client_handle =
638- create_and_start_client ( & ctx. client_config , Arc :: clone ( & wallet) ) . await ;
642+ let client_handle = create_and_start_client ( & ctx. client_config , Arc :: clone ( & wallet) ) . await ;
639643
640644 tokio:: time:: sleep ( Duration :: from_millis ( delay_ms) ) . await ;
641645
@@ -744,19 +748,12 @@ async fn test_multiple_transactions_in_single_block() {
744748
745749 let baseline_tx_count = count_wallet_transactions ( & wallet, & wallet_id) . await ;
746750 let baseline_balance = get_spendable_balance ( & wallet, & wallet_id) . await ;
747- tracing:: info!(
748- "Baseline: tx_count={}, balance={}" ,
749- baseline_tx_count,
750- baseline_balance
751- ) ;
751+ tracing:: info!( "Baseline: tx_count={}, balance={}" , baseline_tx_count, baseline_balance) ;
752752
753753 // Send 3 transactions of different amounts to the SPV wallet
754754 let receive_address = get_wallet_receive_address ( & wallet, & wallet_id) . await ;
755- let amounts = [
756- Amount :: from_sat ( 50_000_000 ) ,
757- Amount :: from_sat ( 75_000_000 ) ,
758- Amount :: from_sat ( 120_000_000 ) ,
759- ] ;
755+ let amounts =
756+ [ Amount :: from_sat ( 50_000_000 ) , Amount :: from_sat ( 75_000_000 ) , Amount :: from_sat ( 120_000_000 ) ] ;
760757 let mut txids = Vec :: new ( ) ;
761758 for amount in & amounts {
762759 let txid = ctx. dashd . node . send_to_address ( & receive_address, * amount) ;
@@ -792,11 +789,7 @@ async fn test_multiple_transactions_in_single_block() {
792789 final_balance < baseline_balance,
793790 "Balance should decrease by fees for internal transfers"
794791 ) ;
795- assert ! (
796- fees_paid < 1_000_000 ,
797- "Total fees ({}) should be reasonable" ,
798- fees_paid
799- ) ;
792+ assert ! ( fees_paid < 1_000_000 , "Total fees ({}) should be reasonable" , fees_paid) ;
800793
801794 for txid in & txids {
802795 assert ! (
@@ -836,18 +829,11 @@ async fn test_multiple_transactions_across_blocks() {
836829
837830 let baseline_tx_count = count_wallet_transactions ( & wallet, & wallet_id) . await ;
838831 let baseline_balance = get_spendable_balance ( & wallet, & wallet_id) . await ;
839- tracing:: info!(
840- "Baseline: tx_count={}, balance={}" ,
841- baseline_tx_count,
842- baseline_balance
843- ) ;
832+ tracing:: info!( "Baseline: tx_count={}, balance={}" , baseline_tx_count, baseline_balance) ;
844833
845834 // Send 1 tx per block, 3 iterations
846- let amounts = [
847- Amount :: from_sat ( 30_000_000 ) ,
848- Amount :: from_sat ( 60_000_000 ) ,
849- Amount :: from_sat ( 90_000_000 ) ,
850- ] ;
835+ let amounts =
836+ [ Amount :: from_sat ( 30_000_000 ) , Amount :: from_sat ( 60_000_000 ) , Amount :: from_sat ( 90_000_000 ) ] ;
851837 let miner_address = ctx. dashd . node . get_new_address_from_wallet ( "default" ) ;
852838 let mut current_height = ctx. dashd . expected_height ;
853839 let mut txids = Vec :: new ( ) ;
@@ -886,11 +872,7 @@ async fn test_multiple_transactions_across_blocks() {
886872 final_balance < baseline_balance,
887873 "Balance should decrease by fees for internal transfers"
888874 ) ;
889- assert ! (
890- fees_paid < 1_000_000 ,
891- "Total fees ({}) should be reasonable" ,
892- fees_paid
893- ) ;
875+ assert ! ( fees_paid < 1_000_000 , "Total fees ({}) should be reasonable" , fees_paid) ;
894876
895877 for txid in & txids {
896878 assert ! (
@@ -930,11 +912,22 @@ async fn test_sync_with_peer_disconnection() {
930912
931913 fn is_progress_event ( event : & SyncEvent ) -> bool {
932914 match event {
933- SyncEvent :: BlockHeadersStored { .. }
934- | SyncEvent :: FilterHeadersStored { .. }
935- | SyncEvent :: FiltersStored { .. }
936- | SyncEvent :: BlocksNeeded { .. } => true ,
937- SyncEvent :: BlockProcessed { new_addresses, .. } => !new_addresses. is_empty ( ) ,
915+ SyncEvent :: BlockHeadersStored {
916+ ..
917+ }
918+ | SyncEvent :: FilterHeadersStored {
919+ ..
920+ }
921+ | SyncEvent :: FiltersStored {
922+ ..
923+ }
924+ | SyncEvent :: BlocksNeeded {
925+ ..
926+ } => true ,
927+ SyncEvent :: BlockProcessed {
928+ new_addresses,
929+ ..
930+ } => !new_addresses. is_empty ( ) ,
938931 _ => false ,
939932 }
940933 }
@@ -1065,11 +1058,22 @@ async fn test_sync_with_peer_disconnection_non_exclusive() {
10651058
10661059 fn is_progress_event ( event : & SyncEvent ) -> bool {
10671060 match event {
1068- SyncEvent :: BlockHeadersStored { .. }
1069- | SyncEvent :: FilterHeadersStored { .. }
1070- | SyncEvent :: FiltersStored { .. }
1071- | SyncEvent :: BlocksNeeded { .. } => true ,
1072- SyncEvent :: BlockProcessed { new_addresses, .. } => !new_addresses. is_empty ( ) ,
1061+ SyncEvent :: BlockHeadersStored {
1062+ ..
1063+ }
1064+ | SyncEvent :: FilterHeadersStored {
1065+ ..
1066+ }
1067+ | SyncEvent :: FiltersStored {
1068+ ..
1069+ }
1070+ | SyncEvent :: BlocksNeeded {
1071+ ..
1072+ } => true ,
1073+ SyncEvent :: BlockProcessed {
1074+ new_addresses,
1075+ ..
1076+ } => !new_addresses. is_empty ( ) ,
10731077 _ => false ,
10741078 }
10751079 }
0 commit comments