From 53fb155e5bdba206fb405a159c06b338a8ce72d7 Mon Sep 17 00:00:00 2001 From: rajarshimaitra Date: Sun, 14 Aug 2022 20:14:35 +0530 Subject: [PATCH] Set the sync time in populate test db. This allows to retrieve the right wallet balance. Or else it will just assume the wallet db is never synced. Add a test to confirm behavior. --- src/database/memory.rs | 7 +++++++ src/wallet/mod.rs | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/database/memory.rs b/src/database/memory.rs index 7d806eb4a..912568c9b 100644 --- a/src/database/memory.rs +++ b/src/database/memory.rs @@ -520,6 +520,13 @@ macro_rules! populate_test_db { timestamp: 0, }); + let sync_time = BlockTime { + height: current_height.unwrap(), + timestamp: 0 + }; + + db.set_sync_time(SyncTime{block_time: sync_time}).unwrap(); + let tx_details = $crate::TransactionDetails { transaction: Some(tx.clone()), txid, diff --git a/src/wallet/mod.rs b/src/wallet/mod.rs index f7f7dc526..2c246c57b 100644 --- a/src/wallet/mod.rs +++ b/src/wallet/mod.rs @@ -2113,6 +2113,12 @@ pub(crate) mod test { }; } + #[test] + fn test_get_funded_wallet_balance() { + let (wallet, _, _) = get_funded_wallet(get_test_wpkh()); + assert_eq!(wallet.get_balance().unwrap().confirmed, 50000); + } + #[test] #[should_panic(expected = "NoRecipients")] fn test_create_tx_empty_recipients() {