Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions resources/scenarios/commander.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import signal
import sys
import tempfile
import threading
from time import sleep
from typing import Dict

from kubernetes import client, config
Expand Down Expand Up @@ -100,6 +102,30 @@ def b64_to_hex(b64, reverse=False):
else:
return base64.b64decode(b64).hex()

def wait_for_tanks_connected(self):
def tank_connected(self, tank):
while True:
peers = tank.getpeerinfo()
count = sum(
1
for peer in peers
if peer.get("connection_type") == "manual" or peer.get("addnode") is True
)
self.log.info(f"Tank {tank.tank} connected to {count}/{tank.init_peers} peers")
if count >= tank.init_peers:
break
else:
sleep(1)

conn_threads = [
threading.Thread(target=tank_connected, args=(self, tank)) for tank in self.nodes
]
for thread in conn_threads:
thread.start()

all(thread.join() is None for thread in conn_threads)
self.log.info("Network connected")

def handle_sigterm(self, signum, frame):
print("SIGTERM received, stopping...")
self.shutdown()
Expand Down
24 changes: 1 addition & 23 deletions resources/scenarios/ln_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,7 @@ def run_test(self):
# L1 P2P
##
self.log.info("Waiting for L1 p2p network connections...")

def tank_connected(self, tank):
while True:
peers = tank.getpeerinfo()
count = sum(
1
for peer in peers
if peer.get("connection_type") == "manual" or peer.get("addnode") is True
)
self.log.info(f"Tank {tank.tank} connected to {count}/{tank.init_peers} peers")
if count >= tank.init_peers:
break
else:
sleep(1)

conn_threads = [
threading.Thread(target=tank_connected, args=(self, tank)) for tank in self.nodes
]
for thread in conn_threads:
thread.start()

all(thread.join() is None for thread in conn_threads)
self.log.info("Network connected")
self.wait_for_tanks_connected()

##
# MINER
Expand Down
Loading