Skip to content

Commit 43b7d4d

Browse files
authored
Merge pull request #305 from willcl-ark/fix-incorrect-version
tank: fix default version string
2 parents b1f9970 + e17b084 commit 43b7d4d

File tree

3 files changed

+8
-37
lines changed

3 files changed

+8
-37
lines changed

src/warnet/lnnode.py

-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ def __init__(self, warnet, tank, impl, image, backend: BackendInterface, cb=None
2020
self.ipv4 = generate_ipv4_addr(self.warnet.subnet)
2121
self.rpc_port = 10009
2222

23-
def __str__(self):
24-
return f"LNNode: index={self.tank.index}, ipv4={self.ipv4}, rpc_port={self.rpc_port}"
25-
2623
@property
2724
def status(self) -> RunningStatus:
2825
return self.warnet.container_interface.get_status(self.tank.index, ServiceType.LIGHTNING)

src/warnet/tank.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(self, index: int, config_dir: Path, warnet):
3030
self.warnet = warnet
3131
self.network_name = warnet.network_name
3232
self.bitcoin_network = warnet.bitcoin_network
33-
self.version = "25.1"
33+
self.version: str = ""
3434
self.image: str = ""
3535
self.bitcoin_config = ""
3636
self.conf_file = None
@@ -51,22 +51,22 @@ def __init__(self, index: int, config_dir: Path, warnet):
5151
# indicating which tanks to initially connect to
5252
self.init_peers = []
5353

54-
def __str__(self) -> str:
55-
return f"Tank(index: {self.index}, version: {self.version}, conf: {self.bitcoin_config}, conf file: {self.conf_file}, netem: {self.netem}, IPv4: {self._ipv4})"
56-
57-
def _parse_version(self):
58-
if self.version not in SUPPORTED_TAGS or ("/" in self.version and "#" in self.version):
54+
def _parse_version(self, version):
55+
if not version:
56+
return
57+
if version not in SUPPORTED_TAGS and not ("/" in version and "#" in version):
5958
raise Exception(
6059
f"Unsupported version: can't be generated from Docker images: {self.version}"
6160
)
61+
self.version = version
6262

6363
def parse_graph_node(self, node):
6464
# Dynamically parse properties based on the schema
6565
graph_properties = {}
6666
for property, specs in self.warnet.node_schema["properties"].items():
6767
value = node.get(property, specs.get("default"))
6868
if property == "version":
69-
self._parse_version()
69+
self._parse_version(value)
7070
setattr(self, property, value)
7171
graph_properties[property] = value
7272

src/warnet/warnet.py

+1-27
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,6 @@ def __init__(self, config_dir, backend, network_name: str):
3838
self.backend = backend
3939
self.node_schema = load_schema()
4040

41-
def __str__(self) -> str:
42-
# TODO: bitcoin_conf and tc_netem can be added back in to this table
43-
# if we write a helper function that can text-wrap inside a column
44-
template = (
45-
"\t" + "%-8.8s" + "%-25.24s" + "%-18.18s" + "%-18.18s" + "%-18.18s" + "%-18.18s" + "\n"
46-
)
47-
tanks_str = template % ("Index", "Version", "IPv4", "LN", "LN Image", "LN IPv4")
48-
for tank in self.tanks:
49-
tanks_str += template % (
50-
tank.index,
51-
tank.version,
52-
tank.ipv4,
53-
tank.lnnode.impl if tank.lnnode is not None else None,
54-
tank.lnnode.image if tank.lnnode is not None else None,
55-
tank.lnnode.ipv4 if tank.lnnode is not None else None,
56-
)
57-
return (
58-
f"Warnet:\n"
59-
f"\tTemp Directory: {self.config_dir}\n"
60-
f"\tBitcoin Network: {self.bitcoin_network}\n"
61-
f"\tDocker Network: {self.network_name}\n"
62-
f"\tSubnet: {self.subnet}\n"
63-
f"\tGraph: {self.graph}\n"
64-
f"Tanks:\n{tanks_str}"
65-
)
66-
6741
def _warnet_dict_representation(self) -> dict:
6842
repr = {}
6943
# Warnet
@@ -98,7 +72,7 @@ def _warnet_dict_representation(self) -> dict:
9872
has_ln = any(tank.lnnode and tank.lnnode.impl for tank in self.tanks)
9973
tanks = []
10074
for tank in self.tanks:
101-
tank_data = [tank.index, tank.version, tank.ipv4, tank.bitcoin_config, tank.netem]
75+
tank_data = [tank.index, tank.version if tank.version else tank.image, tank.ipv4, tank.bitcoin_config, tank.netem]
10276
if has_ln:
10377
tank_data.extend(
10478
[

0 commit comments

Comments
 (0)