aboutsummaryrefslogtreecommitdiff
path: root/test/functional/wallet_importdescriptors.py
diff options
context:
space:
mode:
authorishaanam <ishaana.misra@gmail.com>2023-03-04 16:18:43 -0500
committerishaanam <ishaana.misra@gmail.com>2023-03-15 17:27:57 -0400
commitdbeca792a9980085d00be0f9d78187ca3a4d7cdc (patch)
tree13af21a80ee15059abf319445a8e58465a7b817a /test/functional/wallet_importdescriptors.py
parent40c6c85c05812ee8bf824b639307b1ac17a001c4 (diff)
test: fix race condition in encrypted wallet rescan tests
Diffstat (limited to 'test/functional/wallet_importdescriptors.py')
-rwxr-xr-xtest/functional/wallet_importdescriptors.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/test/functional/wallet_importdescriptors.py b/test/functional/wallet_importdescriptors.py
index e66eb2c289..b4f20f0344 100755
--- a/test/functional/wallet_importdescriptors.py
+++ b/test/functional/wallet_importdescriptors.py
@@ -15,6 +15,9 @@ variants.
- `test_address()` is called to call getaddressinfo for an address on node1
and test the values returned."""
+import threading
+
+from test_framework.authproxy import JSONRPCException
from test_framework.blocktools import COINBASE_MATURITY
from test_framework.test_framework import BitcoinTestFramework
from test_framework.descriptors import descsum_create
@@ -687,11 +690,26 @@ class ImportDescriptorsTest(BitcoinTestFramework):
descriptor["timestamp"] = 0
descriptor["next_index"] = 0
- batch = []
- batch.append(encrypted_wallet.walletpassphrase.get_request("passphrase", 3))
- batch.append(encrypted_wallet.importdescriptors.get_request([descriptor]))
+ encrypted_wallet.walletpassphrase("passphrase", 99999)
+ t = threading.Thread(target=encrypted_wallet.importdescriptors, args=([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)
+
+ 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']
- encrypted_wallet.batch(batch)
+ t.join()
assert_equal(temp_wallet.getbalance(), encrypted_wallet.getbalance())