Skip to content

Commit 32d9f37

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#23596: test: fix wallet_transactiontime_rescan.py --descriptors and add to test runner
e4a54af test: add wallet_transactiontime_rescan.py --descriptors to test_runner.py (Sebastian Falbesoner) b60e02e test: fix test wallet_transactiontime_rescan.py for descriptor wallets (Sebastian Falbesoner) a905ed1 test: refactor: use `set_node_times` helper in wallet_transactiontime_rescan.py (Sebastian Falbesoner) Pull request description: The functional test wallet_transactiontime_rescan.py currently fails on master branch, if descriptor wallets are used (argument `--descriptors`). This is due to the fact that in this case, the test framework maps the importaddress RPC calls to the importdescriptors RPC (rescan=False -> timestamp='now'), which always rescans blocks of the past 2 hours, based on the current MTP timestamp. In order to avoid importing the last address (wo3), we generate 10 more blocks with advanced time, to ensure that the balance after importing is zero: https://github.com/bitcoin/bitcoin/blob/681b25e3cd7d084f642693152322ed9a40f33ba0/test/functional/wallet_transactiontime_rescan.py#L125-L134 Calling this test with descriptor wallets is also added to test runner. Fixes #23562. ACKs for top commit: Sjors: tACK e4a54af brunoerg: tACK e4a54af Tree-SHA512: 9fd8e298d48dd7947b1218d61a1a66c1241b3dbb14451b0ec7cd30caa74ee540e7ee5a7bd10d421b9e3b6e549fa5c3e85bd02496436128b433b328118642f600
2 parents 22feb7f + e4a54af commit 32d9f37

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

test/functional/test_runner.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@
178178
'rpc_rawtransaction.py --legacy-wallet',
179179
'rpc_rawtransaction.py --descriptors',
180180
'wallet_groups.py --legacy-wallet',
181-
'wallet_transactiontime_rescan.py',
181+
'wallet_transactiontime_rescan.py --descriptors',
182+
'wallet_transactiontime_rescan.py --legacy-wallet',
182183
'p2p_addrv2_relay.py',
183184
'wallet_groups.py --descriptors',
184185
'p2p_compactblocks_hb.py',

test/functional/wallet_transactiontime_rescan.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
from test_framework.blocktools import COINBASE_MATURITY
1111
from test_framework.test_framework import BitcoinTestFramework
1212
from test_framework.util import (
13-
assert_equal
13+
assert_equal,
14+
set_node_times,
1415
)
1516

1617

@@ -35,9 +36,7 @@ def run_test(self):
3536

3637
# synchronize nodes and time
3738
self.sync_all()
38-
minernode.setmocktime(cur_time)
39-
usernode.setmocktime(cur_time)
40-
restorenode.setmocktime(cur_time)
39+
set_node_times(self.nodes, cur_time)
4140

4241
# prepare miner wallet
4342
minernode.createwallet(wallet_name='default')
@@ -68,9 +67,7 @@ def run_test(self):
6867

6968
# synchronize nodes and time
7069
self.sync_all()
71-
minernode.setmocktime(cur_time + ten_days)
72-
usernode.setmocktime(cur_time + ten_days)
73-
restorenode.setmocktime(cur_time + ten_days)
70+
set_node_times(self.nodes, cur_time + ten_days)
7471
# send 10 btc to user's first watch-only address
7572
self.log.info('Send 10 btc to user')
7673
miner_wallet.sendtoaddress(wo1, 10)
@@ -81,9 +78,7 @@ def run_test(self):
8178

8279
# synchronize nodes and time
8380
self.sync_all()
84-
minernode.setmocktime(cur_time + ten_days + ten_days)
85-
usernode.setmocktime(cur_time + ten_days + ten_days)
86-
restorenode.setmocktime(cur_time + ten_days + ten_days)
81+
set_node_times(self.nodes, cur_time + ten_days + ten_days)
8782
# send 5 btc to our second watch-only address
8883
self.log.info('Send 5 btc to user')
8984
miner_wallet.sendtoaddress(wo2, 5)
@@ -94,9 +89,7 @@ def run_test(self):
9489

9590
# synchronize nodes and time
9691
self.sync_all()
97-
minernode.setmocktime(cur_time + ten_days + ten_days + ten_days)
98-
usernode.setmocktime(cur_time + ten_days + ten_days + ten_days)
99-
restorenode.setmocktime(cur_time + ten_days + ten_days + ten_days)
92+
set_node_times(self.nodes, cur_time + ten_days + ten_days + ten_days)
10093
# send 1 btc to our third watch-only address
10194
self.log.info('Send 1 btc to user')
10295
miner_wallet.sendtoaddress(wo3, 1)
@@ -126,6 +119,14 @@ def run_test(self):
126119
restorenode.createwallet(wallet_name='wo', disable_private_keys=True)
127120
restorewo_wallet = restorenode.get_wallet_rpc('wo')
128121

122+
# for descriptor wallets, the test framework maps the importaddress RPC to the
123+
# importdescriptors RPC (with argument 'timestamp'='now'), which always rescans
124+
# blocks of the past 2 hours, based on the current MTP timestamp; in order to avoid
125+
# importing the last address (wo3), we advance the time further and generate 10 blocks
126+
if self.options.descriptors:
127+
set_node_times(self.nodes, cur_time + ten_days + ten_days + ten_days + ten_days)
128+
self.generatetoaddress(minernode, 10, m1)
129+
129130
restorewo_wallet.importaddress(wo1, rescan=False)
130131
restorewo_wallet.importaddress(wo2, rescan=False)
131132
restorewo_wallet.importaddress(wo3, rescan=False)

0 commit comments

Comments
 (0)