Split test update thread.
This commit is contained in:
parent
269d10aeda
commit
325a846f47
@ -141,15 +141,17 @@ def callnoderpc(node_id, method, params=[], wallet=None, base_rpc_port=BASE_RPC_
|
||||
|
||||
|
||||
def run_coins_loop(cls):
|
||||
global stop_test
|
||||
while not stop_test:
|
||||
time.sleep(1.0)
|
||||
try:
|
||||
if cls.btc_addr is not None:
|
||||
btcRpc('generatetoaddress 1 {}'.format(cls.btc_addr))
|
||||
time.sleep(1.0)
|
||||
except Exception as e:
|
||||
logging.warning('run_coins_loop ' + str(e))
|
||||
|
||||
|
||||
|
||||
def run_loop(cls):
|
||||
global stop_test
|
||||
while not stop_test:
|
||||
for c in cls.swap_clients:
|
||||
c.update()
|
||||
|
@ -204,13 +204,21 @@ def signal_handler(sig, frame):
|
||||
delay_event.set()
|
||||
|
||||
|
||||
def run_coins_loop(cls):
|
||||
while not stop_test:
|
||||
time.sleep(1.0)
|
||||
try:
|
||||
nmcRpc('generatetoaddress 1 {}'.format(cls.nmc_addr))
|
||||
btcRpc('generatetoaddress 1 {}'.format(cls.btc_addr))
|
||||
except Exception as e:
|
||||
logging.warning('run_coins_loop ' + str(e))
|
||||
|
||||
|
||||
def run_loop(self):
|
||||
while not stop_test:
|
||||
time.sleep(1)
|
||||
for c in self.swap_clients:
|
||||
c.update()
|
||||
nmcRpc('generatetoaddress 1 {}'.format(self.nmc_addr))
|
||||
btcRpc('generatetoaddress 1 {}'.format(self.btc_addr))
|
||||
|
||||
|
||||
def make_part_cli_rpc_func(node_id):
|
||||
@ -260,6 +268,7 @@ class Test(unittest.TestCase):
|
||||
cls.daemons.append(startDaemon(os.path.join(cfg.TEST_DATADIRS, str(i)), cfg.PARTICL_BINDIR, cfg.PARTICLD))
|
||||
logging.info('Started %s %d', cfg.PARTICLD, cls.daemons[-1].pid)
|
||||
|
||||
for i in range(NUM_NODES):
|
||||
rpc = make_part_cli_rpc_func(i)
|
||||
waitForRPC(rpc)
|
||||
if i == 0:
|
||||
@ -271,8 +280,6 @@ class Test(unittest.TestCase):
|
||||
else:
|
||||
rpc('extkeyimportmaster', [rpc('mnemonic', ['new'])['master']])
|
||||
|
||||
time.sleep(1)
|
||||
for i in range(NUM_NODES):
|
||||
basicswap_dir = os.path.join(os.path.join(cfg.TEST_DATADIRS, str(i)), 'basicswap')
|
||||
settings_path = os.path.join(basicswap_dir, cfg.CONFIG_FILENAME)
|
||||
with open(settings_path) as fs:
|
||||
@ -319,12 +326,27 @@ class Test(unittest.TestCase):
|
||||
cls.update_thread = threading.Thread(target=run_loop, args=(cls,))
|
||||
cls.update_thread.start()
|
||||
|
||||
cls.coins_update_thread = threading.Thread(target=run_coins_loop, args=(cls,))
|
||||
cls.coins_update_thread.start()
|
||||
|
||||
# Wait for height, or sequencelock is thrown off by genesis blocktime
|
||||
num_blocks = 3
|
||||
logging.info('Waiting for Particl chain height %d', num_blocks)
|
||||
for i in range(60):
|
||||
particl_blocks = cls.swap_clients[0].callrpc('getblockchaininfo')['blocks']
|
||||
print('particl_blocks', particl_blocks)
|
||||
if particl_blocks >= num_blocks:
|
||||
break
|
||||
delay_event.wait(1)
|
||||
assert(particl_blocks >= num_blocks)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
global stop_test
|
||||
logging.info('Finalising')
|
||||
stop_test = True
|
||||
cls.update_thread.join()
|
||||
cls.coins_update_thread.join()
|
||||
for t in cls.http_threads:
|
||||
t.stop()
|
||||
t.join()
|
||||
|
@ -212,13 +212,21 @@ def signal_handler(sig, frame):
|
||||
delay_event.set()
|
||||
|
||||
|
||||
def run_loop(self):
|
||||
def run_coins_loop(cls):
|
||||
while not stop_test:
|
||||
try:
|
||||
time.sleep(1.0)
|
||||
ltcRpc('generatetoaddress 1 {}'.format(cls.ltc_addr))
|
||||
btcRpc('generatetoaddress 1 {}'.format(cls.btc_addr))
|
||||
except Exception as e:
|
||||
logging.warning('run_coins_loop ' + str(e))
|
||||
|
||||
|
||||
def run_loop(cls):
|
||||
while not stop_test:
|
||||
time.sleep(1)
|
||||
for c in self.swap_clients:
|
||||
for c in cls.swap_clients:
|
||||
c.update()
|
||||
ltcRpc('generatetoaddress 1 {}'.format(self.ltc_addr))
|
||||
btcRpc('generatetoaddress 1 {}'.format(self.btc_addr))
|
||||
|
||||
|
||||
def make_part_cli_rpc_func(node_id):
|
||||
@ -328,6 +336,9 @@ class Test(unittest.TestCase):
|
||||
cls.update_thread = threading.Thread(target=run_loop, args=(cls,))
|
||||
cls.update_thread.start()
|
||||
|
||||
cls.coins_update_thread = threading.Thread(target=run_coins_loop, args=(cls,))
|
||||
cls.coins_update_thread.start()
|
||||
|
||||
# Wait for height, or sequencelock is thrown off by genesis blocktime
|
||||
num_blocks = 3
|
||||
logging.info('Waiting for Particl chain height %d', num_blocks)
|
||||
@ -345,6 +356,7 @@ class Test(unittest.TestCase):
|
||||
logging.info('Finalising')
|
||||
stop_test = True
|
||||
cls.update_thread.join()
|
||||
cls.coins_update_thread.join()
|
||||
for t in cls.http_threads:
|
||||
t.stop()
|
||||
t.join()
|
||||
|
@ -237,18 +237,18 @@ def callnoderpc(node_id, method, params=[], wallet=None, base_rpc_port=BASE_RPC_
|
||||
|
||||
|
||||
def run_coins_loop(cls):
|
||||
global stop_test
|
||||
while not stop_test:
|
||||
time.sleep(1.0)
|
||||
try:
|
||||
if cls.btc_addr is not None:
|
||||
btcRpc('generatetoaddress 1 {}'.format(cls.btc_addr))
|
||||
|
||||
if cls.xmr_addr is not None:
|
||||
callrpc_xmr_na(XMR_BASE_RPC_PORT + 1, 'generateblocks', {'wallet_address': cls.xmr_addr, 'amount_of_blocks': 1})
|
||||
time.sleep(1.0)
|
||||
except Exception as e:
|
||||
logging.warning('run_coins_loop ' + str(e))
|
||||
|
||||
|
||||
def run_loop(cls):
|
||||
global stop_test
|
||||
while not stop_test:
|
||||
for c in cls.swap_clients:
|
||||
c.update()
|
||||
|
Loading…
Reference in New Issue
Block a user