mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-01 00:10:44 +01:00
test: Replace threading with concurrent.futures
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
"""Test transaction time during old block rescanning
|
||||
"""
|
||||
|
||||
import threading
|
||||
import concurrent.futures
|
||||
import time
|
||||
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
@@ -201,25 +201,24 @@ class TransactionTimeRescanTest(BitcoinTestFramework):
|
||||
encrypted_wallet.walletpassphrase("passphrase", 99999)
|
||||
encrypted_wallet.sethdseed(seed=hd_seed)
|
||||
|
||||
t = threading.Thread(target=encrypted_wallet.rescanblockchain)
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=1) as thread:
|
||||
with minernode.assert_debug_log(expected_msgs=["Rescan started from block 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206... (slow variant inspecting all blocks)"], timeout=5):
|
||||
rescanning = thread.submit(encrypted_wallet.rescanblockchain)
|
||||
|
||||
with minernode.assert_debug_log(expected_msgs=[f'Rescan started from block 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206... (slow variant inspecting all blocks)'], timeout=5):
|
||||
t.start()
|
||||
# set the passphrase timeout to 1 to test that the wallet remains unlocked during the rescan
|
||||
minernode.cli("-rpcwallet=encrypted_wallet").walletpassphrase("passphrase", 1)
|
||||
|
||||
# set the passphrase timeout to 1 to test that the wallet remains unlocked during the rescan
|
||||
minernode.cli("-rpcwallet=encrypted_wallet").walletpassphrase("passphrase", 1)
|
||||
try:
|
||||
minernode.cli("-rpcwallet=encrypted_wallet").walletlock()
|
||||
except JSONRPCException as e:
|
||||
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"]
|
||||
|
||||
try:
|
||||
minernode.cli("-rpcwallet=encrypted_wallet").walletlock()
|
||||
except JSONRPCException as e:
|
||||
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']
|
||||
try:
|
||||
minernode.cli("-rpcwallet=encrypted_wallet").walletpassphrasechange("passphrase", "newpassphrase")
|
||||
except JSONRPCException as e:
|
||||
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"]
|
||||
|
||||
try:
|
||||
minernode.cli("-rpcwallet=encrypted_wallet").walletpassphrasechange("passphrase", "newpassphrase")
|
||||
except JSONRPCException as e:
|
||||
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']
|
||||
|
||||
t.join()
|
||||
assert_equal(rescanning.result(), {"start_height": 0, "stop_height": 803})
|
||||
|
||||
assert_equal(encrypted_wallet.getbalance(), temp_wallet.getbalance())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user