0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-03 09:56:38 -05:00

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
This commit is contained in:
MarcoFalke 2021-12-06 12:28:20 +01:00
commit 32d9f3770a
No known key found for this signature in database
GPG key ID: CE2B75697E69A548
2 changed files with 16 additions and 14 deletions

View file

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

View file

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