|
5 | 5 | """Test transaction time during old block rescanning
|
6 | 6 | """
|
7 | 7 |
|
| 8 | +import threading |
8 | 9 | import time
|
9 | 10 |
|
| 11 | +from test_framework.authproxy import JSONRPCException |
10 | 12 | from test_framework.blocktools import COINBASE_MATURITY
|
11 | 13 | from test_framework.test_framework import BitcoinTestFramework
|
12 | 14 | from test_framework.util import (
|
@@ -196,14 +198,28 @@ def run_test(self):
|
196 | 198 | minernode.createwallet("encrypted_wallet", blank=True, passphrase="passphrase", descriptors=False)
|
197 | 199 | encrypted_wallet = minernode.get_wallet_rpc("encrypted_wallet")
|
198 | 200 |
|
199 |
| - encrypted_wallet.walletpassphrase("passphrase", 1) |
| 201 | + encrypted_wallet.walletpassphrase("passphrase", 99999) |
200 | 202 | encrypted_wallet.sethdseed(seed=hd_seed)
|
201 | 203 |
|
202 |
| - batch = [] |
203 |
| - batch.append(encrypted_wallet.walletpassphrase.get_request("passphrase", 3)) |
204 |
| - batch.append(encrypted_wallet.rescanblockchain.get_request()) |
| 204 | + t = threading.Thread(target=encrypted_wallet.rescanblockchain) |
205 | 205 |
|
206 |
| - encrypted_wallet.batch(batch) |
| 206 | + with minernode.assert_debug_log(expected_msgs=[f'Rescan started from block 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206... (slow variant inspecting all blocks)'], timeout=5): |
| 207 | + t.start() |
| 208 | + |
| 209 | + # set the passphrase timeout to 1 to test that the wallet remains unlocked during the rescan |
| 210 | + minernode.cli("-rpcwallet=encrypted_wallet").walletpassphrase("passphrase", 1) |
| 211 | + |
| 212 | + try: |
| 213 | + minernode.cli("-rpcwallet=encrypted_wallet").walletlock() |
| 214 | + except JSONRPCException as e: |
| 215 | + assert e.error['code'] == -4 and "Error: the wallet is currently being used to rescan the blockchain for related transactions. Please call `abortrescan` before locking the wallet." in e.error['message'] |
| 216 | + |
| 217 | + try: |
| 218 | + minernode.cli("-rpcwallet=encrypted_wallet").walletpassphrasechange("passphrase", "newpassphrase") |
| 219 | + except JSONRPCException as e: |
| 220 | + assert e.error['code'] == -4 and "Error: the wallet is currently being used to rescan the blockchain for related transactions. Please call `abortrescan` before changing the passphrase." in e.error['message'] |
| 221 | + |
| 222 | + t.join() |
207 | 223 |
|
208 | 224 | assert_equal(encrypted_wallet.getbalance(), temp_wallet.getbalance())
|
209 | 225 |
|
|
0 commit comments