|
15 | 15 | - `test_address()` is called to call getaddressinfo for an address on node1
|
16 | 16 | and test the values returned."""
|
17 | 17 |
|
18 |
| -import threading |
| 18 | +import concurrent.futures |
19 | 19 |
|
20 | 20 | from test_framework.authproxy import JSONRPCException
|
21 | 21 | from test_framework.blocktools import COINBASE_MATURITY
|
@@ -691,25 +691,24 @@ def run_test(self):
|
691 | 691 | descriptor["next_index"] = 0
|
692 | 692 |
|
693 | 693 | encrypted_wallet.walletpassphrase("passphrase", 99999)
|
694 |
| - t = threading.Thread(target=encrypted_wallet.importdescriptors, args=([descriptor],)) |
| 694 | + with concurrent.futures.ThreadPoolExecutor(max_workers=1) as thread: |
| 695 | + with self.nodes[0].assert_debug_log(expected_msgs=["Rescan started from block 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206... (slow variant inspecting all blocks)"], timeout=5): |
| 696 | + importing = thread.submit(encrypted_wallet.importdescriptors, requests=[descriptor]) |
695 | 697 |
|
696 |
| - with self.nodes[0].assert_debug_log(expected_msgs=[f'Rescan started from block 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206... (slow variant inspecting all blocks)'], timeout=5): |
697 |
| - t.start() |
| 698 | + # Set the passphrase timeout to 1 to test that the wallet remains unlocked during the rescan |
| 699 | + self.nodes[0].cli("-rpcwallet=encrypted_wallet").walletpassphrase("passphrase", 1) |
698 | 700 |
|
699 |
| - # Set the passphrase timeout to 1 to test that the wallet remains unlocked during the rescan |
700 |
| - self.nodes[0].cli("-rpcwallet=encrypted_wallet").walletpassphrase("passphrase", 1) |
| 701 | + try: |
| 702 | + self.nodes[0].cli("-rpcwallet=encrypted_wallet").walletlock() |
| 703 | + except JSONRPCException as e: |
| 704 | + 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"] |
701 | 705 |
|
702 |
| - try: |
703 |
| - self.nodes[0].cli("-rpcwallet=encrypted_wallet").walletlock() |
704 |
| - except JSONRPCException as e: |
705 |
| - 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'] |
| 706 | + try: |
| 707 | + self.nodes[0].cli("-rpcwallet=encrypted_wallet").walletpassphrasechange("passphrase", "newpassphrase") |
| 708 | + except JSONRPCException as e: |
| 709 | + 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"] |
706 | 710 |
|
707 |
| - try: |
708 |
| - self.nodes[0].cli("-rpcwallet=encrypted_wallet").walletpassphrasechange("passphrase", "newpassphrase") |
709 |
| - except JSONRPCException as e: |
710 |
| - 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'] |
711 |
| - |
712 |
| - t.join() |
| 711 | + assert_equal(importing.result(), [{"success": True}]) |
713 | 712 |
|
714 | 713 | assert_equal(temp_wallet.getbalance(), encrypted_wallet.getbalance())
|
715 | 714 |
|
|
0 commit comments