From d3e4e62feb4bb4a00036a6e7aa141ba2509401e2 Mon Sep 17 00:00:00 2001 From: xdustinface Date: Fri, 28 Nov 2025 10:41:27 +1000 Subject: [PATCH 1/2] call update chain height after block processing --- key-wallet-manager/src/wallet_manager/process_block.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/key-wallet-manager/src/wallet_manager/process_block.rs b/key-wallet-manager/src/wallet_manager/process_block.rs index fae442d58..2b70d1369 100644 --- a/key-wallet-manager/src/wallet_manager/process_block.rs +++ b/key-wallet-manager/src/wallet_manager/process_block.rs @@ -37,7 +37,7 @@ impl WalletInterface for WalletM } } - self.current_height = height; + self.update_height(height); relevant_txids } From 7f62404669ea18decd5a6b5759d9b2d1fc590962 Mon Sep 17 00:00:00 2001 From: xdustinface Date: Fri, 26 Dec 2025 17:05:46 +0100 Subject: [PATCH 2/2] add test --- .../tests/spv_integration_tests.rs | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/key-wallet-manager/tests/spv_integration_tests.rs b/key-wallet-manager/tests/spv_integration_tests.rs index ea855b2b9..9cd1b206d 100644 --- a/key-wallet-manager/tests/spv_integration_tests.rs +++ b/key-wallet-manager/tests/spv_integration_tests.rs @@ -10,6 +10,7 @@ use dashcore_hashes::Hash; use dashcore::bip158::{BlockFilter, BlockFilterWriter}; use key_wallet::wallet::initialization::WalletAccountCreationOptions; +use key_wallet::wallet::managed_wallet_info::wallet_info_interface::WalletInfoInterface; use key_wallet::wallet::managed_wallet_info::ManagedWalletInfo; use key_wallet::Network; use key_wallet_manager::wallet_interface::WalletInterface; @@ -148,3 +149,35 @@ async fn test_filter_caching() { assert_eq!(result1, cached1, "Cached result for block1 should match"); assert_eq!(result2, cached2, "Cached result for block2 should match"); } + +fn assert_wallet_heights(manager: &WalletManager, expected_height: u32) { + assert_eq!(manager.current_height(), expected_height, "height should be {}", expected_height); + for wallet_info in manager.get_all_wallet_infos().values() { + assert_eq!( + wallet_info.synced_height(), + expected_height, + "synced_height should be {}", + expected_height + ); + } +} + +/// Test that the wallet heights are updated after block processing. +#[tokio::test] +async fn test_height_updated_after_block_processing() { + let mut manager = WalletManager::::new(Network::Testnet); + + // Create a wallet + let _wallet_id = manager + .create_wallet_with_random_mnemonic(WalletAccountCreationOptions::Default) + .expect("Failed to create wallet"); + + // Initial state - no blocks processed yet + assert_wallet_heights(&manager, 0); + + for height in [1000, 2000, 3000] { + let block = create_test_block(height, vec![create_test_transaction(1000)]); + manager.process_block(&block, height).await; + assert_wallet_heights(&manager, height); + } +}