aboutsummaryrefslogtreecommitdiff
path: root/test/functional/wallet_reindex.py
diff options
context:
space:
mode:
authorfurszy <matiasfurszyfer@protonmail.com>2023-11-21 21:48:57 -0300
committerfurszy <matiasfurszyfer@protonmail.com>2023-12-05 18:55:35 -0300
commit1ce45baed7dd2da3f1cb85c9c25110e5537451ae (patch)
treece27b30a2adc42d59ad26cb49e00f63ac6e22e65 /test/functional/wallet_reindex.py
parent83c66444d0604f0a9ec3bc3f89d4f1a810b7cda0 (diff)
downloadbitcoin-1ce45baed7dd2da3f1cb85c9c25110e5537451ae.tar.xz
rpc: getwalletinfo, return wallet 'birthtime'
And add coverage for it
Diffstat (limited to 'test/functional/wallet_reindex.py')
-rwxr-xr-xtest/functional/wallet_reindex.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/test/functional/wallet_reindex.py b/test/functional/wallet_reindex.py
index 95d5fd85ad..5388de4b71 100755
--- a/test/functional/wallet_reindex.py
+++ b/test/functional/wallet_reindex.py
@@ -44,8 +44,10 @@ class WalletReindexTest(BitcoinTestFramework):
self.advance_time(node, BLOCK_TIME)
# Now create a new wallet, and import the descriptor
- node.createwallet(wallet_name='watch_only', disable_private_keys=True, blank=True, load_on_startup=True)
+ node.createwallet(wallet_name='watch_only', disable_private_keys=True, load_on_startup=True)
wallet_watch_only = node.get_wallet_rpc('watch_only')
+ # Blank wallets don't have a birth time
+ assert 'birthtime' not in wallet_watch_only.getwalletinfo()
# For a descriptors wallet: Import address with timestamp=now.
# For legacy wallet: There is no way of importing a script/address with a custom time. The wallet always imports it with birthtime=1.
@@ -53,6 +55,16 @@ class WalletReindexTest(BitcoinTestFramework):
wallet_watch_only.importaddress(wallet_addr, rescan=False)
assert_equal(len(wallet_watch_only.listtransactions()), 0)
+ # Depending on the wallet type, the birth time changes.
+ wallet_birthtime = wallet_watch_only.getwalletinfo()['birthtime']
+ if self.options.descriptors:
+ # As blocks were generated every 10 min, the chain MTP timestamp is node_time - 60 min.
+ assert_equal(self.node_time - BLOCK_TIME * 6, wallet_birthtime)
+ else:
+ # No way of importing scripts/addresses with a custom time on a legacy wallet.
+ # It's always set to the beginning of time.
+ assert_equal(wallet_birthtime, 1)
+
# Rescan the wallet to detect the missing transaction
wallet_watch_only.rescanblockchain()
assert_equal(wallet_watch_only.gettransaction(tx_id)['confirmations'], 50)
@@ -65,7 +77,16 @@ class WalletReindexTest(BitcoinTestFramework):
# Verify the transaction is still 'confirmed' after reindex
wallet_watch_only = node.get_wallet_rpc('watch_only')
- assert_equal(wallet_watch_only.gettransaction(tx_id)['confirmations'], 50)
+ tx_info = wallet_watch_only.gettransaction(tx_id)
+ assert_equal(tx_info['confirmations'], 50)
+
+ # Depending on the wallet type, the birth time changes.
+ if self.options.descriptors:
+ # For descriptors, verify the wallet updated the birth time to the transaction time
+ assert_equal(tx_info['time'], wallet_watch_only.getwalletinfo()['birthtime'])
+ else:
+ # For legacy, as the birth time was set to the beginning of time, verify it did not change
+ assert_equal(wallet_birthtime, 1)
wallet_watch_only.unloadwallet()