@@ -10,6 +10,7 @@ use dashcore_hashes::Hash;
1010
1111use dashcore:: bip158:: { BlockFilter , BlockFilterWriter } ;
1212use key_wallet:: wallet:: initialization:: WalletAccountCreationOptions ;
13+ use key_wallet:: wallet:: managed_wallet_info:: wallet_info_interface:: WalletInfoInterface ;
1314use key_wallet:: wallet:: managed_wallet_info:: ManagedWalletInfo ;
1415use key_wallet:: Network ;
1516use key_wallet_manager:: wallet_interface:: WalletInterface ;
@@ -148,3 +149,35 @@ async fn test_filter_caching() {
148149 assert_eq ! ( result1, cached1, "Cached result for block1 should match" ) ;
149150 assert_eq ! ( result2, cached2, "Cached result for block2 should match" ) ;
150151}
152+
153+ fn assert_wallet_heights ( manager : & WalletManager < ManagedWalletInfo > , expected_height : u32 ) {
154+ assert_eq ! ( manager. current_height( ) , expected_height, "height should be {}" , expected_height) ;
155+ for wallet_info in manager. get_all_wallet_infos ( ) . values ( ) {
156+ assert_eq ! (
157+ wallet_info. synced_height( ) ,
158+ expected_height,
159+ "synced_height should be {}" ,
160+ expected_height
161+ ) ;
162+ }
163+ }
164+
165+ /// Test that the wallet heights are updated after block processing.
166+ #[ tokio:: test]
167+ async fn test_height_updated_after_block_processing ( ) {
168+ let mut manager = WalletManager :: < ManagedWalletInfo > :: new ( Network :: Testnet ) ;
169+
170+ // Create a wallet
171+ let _wallet_id = manager
172+ . create_wallet_with_random_mnemonic ( WalletAccountCreationOptions :: Default )
173+ . expect ( "Failed to create wallet" ) ;
174+
175+ // Initial state - no blocks processed yet
176+ assert_wallet_heights ( & manager, 0 ) ;
177+
178+ for height in [ 1000 , 2000 , 3000 ] {
179+ let block = create_test_block ( height, vec ! [ create_test_transaction( 1000 ) ] ) ;
180+ manager. process_block ( & block, height) . await ;
181+ assert_wallet_heights ( & manager, height) ;
182+ }
183+ }
0 commit comments