From 0c38bbd194e2314d3bf8ff3c2e50db46da7dfc38 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Sat, 2 Mar 2024 13:36:02 +0000 Subject: [PATCH] QA: wallet_reindex: Use `importdescriptors` directly rather than abusing test_framework's `importaddress` wrapper `importdescriptors` is expected to initialise wallet birth time to "now", but `importaddress` initialises it to 1 instead. --- test/functional/wallet_reindex.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/functional/wallet_reindex.py b/test/functional/wallet_reindex.py index 5388de4b71..ad0a0c3151 100755 --- a/test/functional/wallet_reindex.py +++ b/test/functional/wallet_reindex.py @@ -8,6 +8,7 @@ import time from test_framework.blocktools import COINBASE_MATURITY +from test_framework.descriptors import descsum_create from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( assert_equal, @@ -52,7 +53,15 @@ class WalletReindexTest(BitcoinTestFramework): # 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. # In both cases, disable rescan to not detect the transaction. - wallet_watch_only.importaddress(wallet_addr, rescan=False) + if self.options.descriptors: + import_res = wallet_watch_only.importdescriptors([{ + 'desc': descsum_create('addr(' + wallet_addr + ')'), + 'timestamp': 'now', + }]) + assert len(import_res) == 1 + assert import_res[0]['success'] + else: + 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.