diff options
author | João Barbosa <joao.paulo.barbosa@gmail.com> | 2020-06-17 14:00:25 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2020-07-03 09:58:17 +0800 |
commit | eb6b82a5586a0cea5b72c376ff377a7322acb588 (patch) | |
tree | 33bb58d49b9b9c329d1a9713eeb029846c702434 | |
parent | c9b49d28563487e76169c7749b309244cabc70bd (diff) | |
download | bitcoin-eb6b82a5586a0cea5b72c376ff377a7322acb588.tar.xz |
qa: Test concurrent wallet loading
Github-Pull: #19300
Rebased-From: 9b009fae6e2eb0ab2ee7ce7882c3556a9ac363a7
-rwxr-xr-x | test/functional/wallet_multiwallet.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/functional/wallet_multiwallet.py b/test/functional/wallet_multiwallet.py index a2c502f280..294de76b7b 100755 --- a/test/functional/wallet_multiwallet.py +++ b/test/functional/wallet_multiwallet.py @@ -6,19 +6,36 @@ Verify that a bitcoind node can load multiple wallet files """ +from threading import Thread import os import shutil import time +from test_framework.authproxy import JSONRPCException from test_framework.test_framework import BitcoinTestFramework from test_framework.test_node import ErrorMatch from test_framework.util import ( assert_equal, assert_raises_rpc_error, + get_rpc_proxy, ) FEATURE_LATEST = 169900 +got_loading_error = False +def test_load_unload(node, name): + global got_loading_error + for i in range(10): + if got_loading_error: + return + try: + node.loadwallet(name) + node.unloadwallet(name) + except JSONRPCException as e: + if e.error['code'] == -4 and 'Wallet already being loading' in e.error['message']: + got_loading_error = True + return + class MultiWalletTest(BitcoinTestFramework): def set_test_params(self): @@ -219,6 +236,18 @@ class MultiWalletTest(BitcoinTestFramework): w2 = node.get_wallet_rpc(wallet_names[1]) w2.getwalletinfo() + self.log.info("Concurrent wallet loading") + threads = [] + for _ in range(3): + n = node.cli if self.options.usecli else get_rpc_proxy(node.url, 1, timeout=600, coveragedir=node.coverage_dir) + t = Thread(target=test_load_unload, args=(n, wallet_names[2], )) + t.start() + threads.append(t) + for t in threads: + t.join() + global got_loading_error + assert_equal(got_loading_error, True) + self.log.info("Load remaining wallets") for wallet_name in wallet_names[2:]: loadwallet_name = self.nodes[0].loadwallet(wallet_name) |