mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-21 09:32:39 +02:00
qa: Test concurrent wallet loading
This commit is contained in:
parent
b9971ae585
commit
9b009fae6e
@ -7,19 +7,36 @@
|
|||||||
Verify that a bitcoind node can load multiple wallet files
|
Verify that a bitcoind node can load multiple wallet files
|
||||||
"""
|
"""
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
from threading import Thread
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from test_framework.authproxy import JSONRPCException
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.test_node import ErrorMatch
|
from test_framework.test_node import ErrorMatch
|
||||||
from test_framework.util import (
|
from test_framework.util import (
|
||||||
assert_equal,
|
assert_equal,
|
||||||
assert_raises_rpc_error,
|
assert_raises_rpc_error,
|
||||||
|
get_rpc_proxy,
|
||||||
)
|
)
|
||||||
|
|
||||||
FEATURE_LATEST = 169900
|
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):
|
class MultiWalletTest(BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
@ -212,6 +229,18 @@ class MultiWalletTest(BitcoinTestFramework):
|
|||||||
w2 = node.get_wallet_rpc(wallet_names[1])
|
w2 = node.get_wallet_rpc(wallet_names[1])
|
||||||
w2.getwalletinfo()
|
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")
|
self.log.info("Load remaining wallets")
|
||||||
for wallet_name in wallet_names[2:]:
|
for wallet_name in wallet_names[2:]:
|
||||||
loadwallet_name = self.nodes[0].loadwallet(wallet_name)
|
loadwallet_name = self.nodes[0].loadwallet(wallet_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user