Skip to content

Commit

Permalink
Merge pull request #305 from willcl-ark/fix-incorrect-version
Browse files Browse the repository at this point in the history
tank: fix default version string
  • Loading branch information
pinheadmz authored Mar 8, 2024
2 parents b1f9970 + e17b084 commit 43b7d4d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 37 deletions.
3 changes: 0 additions & 3 deletions src/warnet/lnnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ def __init__(self, warnet, tank, impl, image, backend: BackendInterface, cb=None
self.ipv4 = generate_ipv4_addr(self.warnet.subnet)
self.rpc_port = 10009

def __str__(self):
return f"LNNode: index={self.tank.index}, ipv4={self.ipv4}, rpc_port={self.rpc_port}"

@property
def status(self) -> RunningStatus:
return self.warnet.container_interface.get_status(self.tank.index, ServiceType.LIGHTNING)
Expand Down
14 changes: 7 additions & 7 deletions src/warnet/tank.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, index: int, config_dir: Path, warnet):
self.warnet = warnet
self.network_name = warnet.network_name
self.bitcoin_network = warnet.bitcoin_network
self.version = "25.1"
self.version: str = ""
self.image: str = ""
self.bitcoin_config = ""
self.conf_file = None
Expand All @@ -51,22 +51,22 @@ def __init__(self, index: int, config_dir: Path, warnet):
# indicating which tanks to initially connect to
self.init_peers = []

def __str__(self) -> str:
return f"Tank(index: {self.index}, version: {self.version}, conf: {self.bitcoin_config}, conf file: {self.conf_file}, netem: {self.netem}, IPv4: {self._ipv4})"

def _parse_version(self):
if self.version not in SUPPORTED_TAGS or ("/" in self.version and "#" in self.version):
def _parse_version(self, version):
if not version:
return
if version not in SUPPORTED_TAGS and not ("/" in version and "#" in version):
raise Exception(
f"Unsupported version: can't be generated from Docker images: {self.version}"
)
self.version = version

def parse_graph_node(self, node):
# Dynamically parse properties based on the schema
graph_properties = {}
for property, specs in self.warnet.node_schema["properties"].items():
value = node.get(property, specs.get("default"))
if property == "version":
self._parse_version()
self._parse_version(value)
setattr(self, property, value)
graph_properties[property] = value

Expand Down
28 changes: 1 addition & 27 deletions src/warnet/warnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,6 @@ def __init__(self, config_dir, backend, network_name: str):
self.backend = backend
self.node_schema = load_schema()

def __str__(self) -> str:
# TODO: bitcoin_conf and tc_netem can be added back in to this table
# if we write a helper function that can text-wrap inside a column
template = (
"\t" + "%-8.8s" + "%-25.24s" + "%-18.18s" + "%-18.18s" + "%-18.18s" + "%-18.18s" + "\n"
)
tanks_str = template % ("Index", "Version", "IPv4", "LN", "LN Image", "LN IPv4")
for tank in self.tanks:
tanks_str += template % (
tank.index,
tank.version,
tank.ipv4,
tank.lnnode.impl if tank.lnnode is not None else None,
tank.lnnode.image if tank.lnnode is not None else None,
tank.lnnode.ipv4 if tank.lnnode is not None else None,
)
return (
f"Warnet:\n"
f"\tTemp Directory: {self.config_dir}\n"
f"\tBitcoin Network: {self.bitcoin_network}\n"
f"\tDocker Network: {self.network_name}\n"
f"\tSubnet: {self.subnet}\n"
f"\tGraph: {self.graph}\n"
f"Tanks:\n{tanks_str}"
)

def _warnet_dict_representation(self) -> dict:
repr = {}
# Warnet
Expand Down Expand Up @@ -98,7 +72,7 @@ def _warnet_dict_representation(self) -> dict:
has_ln = any(tank.lnnode and tank.lnnode.impl for tank in self.tanks)
tanks = []
for tank in self.tanks:
tank_data = [tank.index, tank.version, tank.ipv4, tank.bitcoin_config, tank.netem]
tank_data = [tank.index, tank.version if tank.version else tank.image, tank.ipv4, tank.bitcoin_config, tank.netem]
if has_ln:
tank_data.extend(
[
Expand Down

0 comments on commit 43b7d4d

Please sign in to comment.