aboutsummaryrefslogtreecommitdiff
path: root/test/functional/wallet_importdescriptors.py
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-03-21 09:47:02 +0100
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-03-21 09:49:39 +0100
commitfa0696e7863af03efbffa026c2060ff2b5720fb1 (patch)
tree1e328f00c18251f94deac43322e7db47d2729ec0 /test/functional/wallet_importdescriptors.py
parent40e1c4d4024b8ad35f2511b2e10bf80c5531dfde (diff)
downloadbitcoin-fa0696e7863af03efbffa026c2060ff2b5720fb1.tar.xz
test: Replace threading with concurrent.futures
Diffstat (limited to 'test/functional/wallet_importdescriptors.py')
-rwxr-xr-xtest/functional/wallet_importdescriptors.py31
1 files changed, 15 insertions, 16 deletions
diff --git a/test/functional/wallet_importdescriptors.py b/test/functional/wallet_importdescriptors.py
index b4f20f0344..4f2db2018a 100755
--- a/test/functional/wallet_importdescriptors.py
+++ b/test/functional/wallet_importdescriptors.py
@@ -15,7 +15,7 @@ variants.
- `test_address()` is called to call getaddressinfo for an address on node1
and test the values returned."""
-import threading
+import concurrent.futures
from test_framework.authproxy import JSONRPCException
from test_framework.blocktools import COINBASE_MATURITY
@@ -691,25 +691,24 @@ class ImportDescriptorsTest(BitcoinTestFramework):
descriptor["next_index"] = 0
encrypted_wallet.walletpassphrase("passphrase", 99999)
- t = threading.Thread(target=encrypted_wallet.importdescriptors, args=([descriptor],))
+ with concurrent.futures.ThreadPoolExecutor(max_workers=1) as thread:
+ with self.nodes[0].assert_debug_log(expected_msgs=["Rescan started from block 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206... (slow variant inspecting all blocks)"], timeout=5):
+ importing = thread.submit(encrypted_wallet.importdescriptors, requests=[descriptor])
- with self.nodes[0].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
+ self.nodes[0].cli("-rpcwallet=encrypted_wallet").walletpassphrase("passphrase", 1)
- # Set the passphrase timeout to 1 to test that the wallet remains unlocked during the rescan
- self.nodes[0].cli("-rpcwallet=encrypted_wallet").walletpassphrase("passphrase", 1)
+ try:
+ self.nodes[0].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:
- self.nodes[0].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:
+ self.nodes[0].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:
- self.nodes[0].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(importing.result(), [{"success": True}])
assert_equal(temp_wallet.getbalance(), encrypted_wallet.getbalance())