Merge bitcoin/bitcoin#23596: test: fix `wallet_transactiontime_rescan.py --descriptors` and add to test runner

e4a54af6b8  test: add wallet_transactiontime_rescan.py --descriptors to test_runner.py (Sebastian Falbesoner)
b60e02e993 test: fix test wallet_transactiontime_rescan.py for descriptor wallets (Sebastian Falbesoner)
a905ed1a61 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:
  681b25e3cd/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 e4a54af6b8

Tree-SHA512: 9fd8e298d48dd7947b1218d61a1a66c1241b3dbb14451b0ec7cd30caa74ee540e7ee5a7bd10d421b9e3b6e549fa5c3e85bd02496436128b433b328118642f600
pull/826/head
MarcoFalke 3 years ago
commit 32d9f3770a
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548

@ -178,7 +178,8 @@ BASE_SCRIPTS = [
'rpc_rawtransaction.py --legacy-wallet',
'rpc_rawtransaction.py --descriptors',
'wallet_groups.py --legacy-wallet',
'wallet_transactiontime_rescan.py',
'wallet_transactiontime_rescan.py --descriptors',
'wallet_transactiontime_rescan.py --legacy-wallet',
'p2p_addrv2_relay.py',
'wallet_groups.py --descriptors',
'p2p_compactblocks_hb.py',

@ -10,7 +10,8 @@ import time
from test_framework.blocktools import COINBASE_MATURITY
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal
assert_equal,
set_node_times,
)
@ -35,9 +36,7 @@ class TransactionTimeRescanTest(BitcoinTestFramework):
# synchronize nodes and time
self.sync_all()
minernode.setmocktime(cur_time)
usernode.setmocktime(cur_time)
restorenode.setmocktime(cur_time)
set_node_times(self.nodes, cur_time)
# prepare miner wallet
minernode.createwallet(wallet_name='default')
@ -68,9 +67,7 @@ class TransactionTimeRescanTest(BitcoinTestFramework):
# synchronize nodes and time
self.sync_all()
minernode.setmocktime(cur_time + ten_days)
usernode.setmocktime(cur_time + ten_days)
restorenode.setmocktime(cur_time + ten_days)
set_node_times(self.nodes, cur_time + ten_days)
# send 10 btc to user's first watch-only address
self.log.info('Send 10 btc to user')
miner_wallet.sendtoaddress(wo1, 10)
@ -81,9 +78,7 @@ class TransactionTimeRescanTest(BitcoinTestFramework):
# synchronize nodes and time
self.sync_all()
minernode.setmocktime(cur_time + ten_days + ten_days)
usernode.setmocktime(cur_time + ten_days + ten_days)
restorenode.setmocktime(cur_time + ten_days + ten_days)
set_node_times(self.nodes, cur_time + ten_days + ten_days)
# send 5 btc to our second watch-only address
self.log.info('Send 5 btc to user')
miner_wallet.sendtoaddress(wo2, 5)
@ -94,9 +89,7 @@ class TransactionTimeRescanTest(BitcoinTestFramework):
# synchronize nodes and time
self.sync_all()
minernode.setmocktime(cur_time + ten_days + ten_days + ten_days)
usernode.setmocktime(cur_time + ten_days + ten_days + ten_days)
restorenode.setmocktime(cur_time + ten_days + ten_days + ten_days)
set_node_times(self.nodes, cur_time + ten_days + ten_days + ten_days)
# send 1 btc to our third watch-only address
self.log.info('Send 1 btc to user')
miner_wallet.sendtoaddress(wo3, 1)
@ -126,6 +119,14 @@ class TransactionTimeRescanTest(BitcoinTestFramework):
restorenode.createwallet(wallet_name='wo', disable_private_keys=True)
restorewo_wallet = restorenode.get_wallet_rpc('wo')
# for descriptor wallets, the test framework maps the importaddress RPC to the
# importdescriptors RPC (with argument '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 advance the time further and generate 10 blocks
if self.options.descriptors:
set_node_times(self.nodes, cur_time + ten_days + ten_days + ten_days + ten_days)
self.generatetoaddress(minernode, 10, m1)
restorewo_wallet.importaddress(wo1, rescan=False)
restorewo_wallet.importaddress(wo2, rescan=False)
restorewo_wallet.importaddress(wo3, rescan=False)

Loading…
Cancel
Save