mirror of
https://github.com/basicswap/basicswap.git
synced 2025-01-10 12:44:33 +00:00
tests: Fix test_reload for Particl v23
This commit is contained in:
parent
7bc411eb98
commit
b5b43a8bf3
3 changed files with 30 additions and 10 deletions
|
@ -653,6 +653,9 @@ def prepareDataDir(coin, settings, chain, particl_mnemonic, extra_opts={}):
|
||||||
fp.write('shared-ringdb-dir={}\n'.format(os.path.join(config_datadir, 'shared-ringdb')))
|
fp.write('shared-ringdb-dir={}\n'.format(os.path.join(config_datadir, 'shared-ringdb')))
|
||||||
fp.write('rpc-login={}:{}\n'.format(core_settings['walletrpcuser'], core_settings['walletrpcpassword']))
|
fp.write('rpc-login={}:{}\n'.format(core_settings['walletrpcuser'], core_settings['walletrpcpassword']))
|
||||||
|
|
||||||
|
if chain == 'regtest':
|
||||||
|
fp.write('allow-mismatched-daemon-version=1\n')
|
||||||
|
|
||||||
if tor_control_password is not None:
|
if tor_control_password is not None:
|
||||||
if not core_settings['manage_daemon']:
|
if not core_settings['manage_daemon']:
|
||||||
fp.write(f'proxy={TOR_PROXY_HOST}:{TOR_PROXY_PORT}\n')
|
fp.write(f'proxy={TOR_PROXY_HOST}:{TOR_PROXY_PORT}\n')
|
||||||
|
|
|
@ -361,7 +361,7 @@ class Test(unittest.TestCase):
|
||||||
num_blocks = 3
|
num_blocks = 3
|
||||||
logging.info('Waiting for Particl chain height %d', num_blocks)
|
logging.info('Waiting for Particl chain height %d', num_blocks)
|
||||||
for i in range(60):
|
for i in range(60):
|
||||||
particl_blocks = cls.swap_clients[0].callrpc('getblockchaininfo')['blocks']
|
particl_blocks = cls.swap_clients[0].callrpc('getblockcount')
|
||||||
print('particl_blocks', particl_blocks)
|
print('particl_blocks', particl_blocks)
|
||||||
if particl_blocks >= num_blocks:
|
if particl_blocks >= num_blocks:
|
||||||
break
|
break
|
||||||
|
|
|
@ -56,6 +56,12 @@ def btcRpc(client_no, cmd):
|
||||||
return callrpc_cli(bin_path, data_path, 'regtest', cmd, 'bitcoin-cli')
|
return callrpc_cli(bin_path, data_path, 'regtest', cmd, 'bitcoin-cli')
|
||||||
|
|
||||||
|
|
||||||
|
def partRpc(client_no, cmd):
|
||||||
|
bin_path = os.path.join(TEST_PATH, 'bin', 'particl')
|
||||||
|
data_path = os.path.join(TEST_PATH, 'client{}'.format(client_no), 'particl')
|
||||||
|
return callrpc_cli(bin_path, data_path, 'regtest', cmd, 'particl-cli')
|
||||||
|
|
||||||
|
|
||||||
def updateThread():
|
def updateThread():
|
||||||
btc_addr = btcRpc(0, 'getnewaddress mining_addr bech32')
|
btc_addr = btcRpc(0, 'getnewaddress mining_addr bech32')
|
||||||
|
|
||||||
|
@ -77,6 +83,23 @@ class Test(unittest.TestCase):
|
||||||
with patch.object(sys, 'argv', testargs):
|
with patch.object(sys, 'argv', testargs):
|
||||||
runSystem.main()
|
runSystem.main()
|
||||||
|
|
||||||
|
def wait_for_node_height(self, port=12701, wallet_ticker='part', wait_for_blocks=3):
|
||||||
|
# Wait for height, or sequencelock is thrown off by genesis blocktime
|
||||||
|
logging.info(f'Waiting for {wallet_ticker} chain height {wait_for_blocks} at port {port}', )
|
||||||
|
for i in range(60):
|
||||||
|
if delay_event.is_set():
|
||||||
|
raise ValueError('Test stopped.')
|
||||||
|
try:
|
||||||
|
wallet = read_json_api(port, f'wallets/{wallet_ticker}')
|
||||||
|
node_blocks = wallet['blocks']
|
||||||
|
print(f'{wallet_ticker} node_blocks {node_blocks}')
|
||||||
|
if node_blocks >= wait_for_blocks:
|
||||||
|
return
|
||||||
|
except Exception as e:
|
||||||
|
print('Error reading wallets', str(e))
|
||||||
|
delay_event.wait(1)
|
||||||
|
raise ValueError(f'wait_for_node_height timed out, {wallet_ticker}, {wait_for_blocks}, {port}')
|
||||||
|
|
||||||
def test_reload(self):
|
def test_reload(self):
|
||||||
global stop_test
|
global stop_test
|
||||||
processes = []
|
processes = []
|
||||||
|
@ -87,20 +110,14 @@ class Test(unittest.TestCase):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
waitForServer(delay_event, 12700)
|
waitForServer(delay_event, 12700)
|
||||||
|
partRpc(0, 'reservebalance false') # WakeThreadStakeMiner
|
||||||
|
self.wait_for_node_height()
|
||||||
|
|
||||||
num_blocks = 500
|
num_blocks = 500
|
||||||
btc_addr = btcRpc(1, 'getnewaddress mining_addr bech32')
|
btc_addr = btcRpc(1, 'getnewaddress mining_addr bech32')
|
||||||
logging.info('Mining %d Bitcoin blocks to %s', num_blocks, btc_addr)
|
logging.info('Mining %d Bitcoin blocks to %s', num_blocks, btc_addr)
|
||||||
btcRpc(1, 'generatetoaddress {} {}'.format(num_blocks, btc_addr))
|
btcRpc(1, 'generatetoaddress {} {}'.format(num_blocks, btc_addr))
|
||||||
|
self.wait_for_node_height(12700, 'btc', num_blocks)
|
||||||
for i in range(20):
|
|
||||||
if delay_event.is_set():
|
|
||||||
raise ValueError('Test stopped.')
|
|
||||||
blocks = btcRpc(0, 'getblockchaininfo')['blocks']
|
|
||||||
if blocks >= num_blocks:
|
|
||||||
break
|
|
||||||
delay_event.wait(2)
|
|
||||||
assert (blocks >= num_blocks)
|
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'addr_from': '-1',
|
'addr_from': '-1',
|
||||||
|
|
Loading…
Reference in a new issue