Skip to content

Commit c954707

Browse files
committed
LN: pass ln node config arguments in from graphml file
1 parent e89515d commit c954707

File tree

5 files changed

+30
-24
lines changed

5 files changed

+30
-24
lines changed

src/schema/node_schema.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
"collect_logs": {"type": "boolean", "default": false},
1313
"build_args": {"type": "string", "default": ""},
1414
"ln": {"type": "string"},
15-
"ln-image": {"type": "string"},
16-
"ln-cb-image": {"type": "string"}
15+
"ln_image": {"type": "string"},
16+
"ln_cb_image": {"type": "string"},
17+
"ln_config": {"type": "string"}
1718
},
1819
"additionalProperties": false,
1920
"oneOf": [

src/warnet/lnnode.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@
1616
])
1717

1818
class LNNode:
19-
def __init__(self, warnet, tank, impl, image, backend: BackendInterface, cb=None):
19+
def __init__(self, warnet, tank, backend: BackendInterface, options):
2020
self.warnet = warnet
2121
self.tank = tank
22-
assert impl == "lnd"
23-
self.impl = impl
24-
self.image = "lightninglabs/lnd:v0.17.0-beta"
25-
if image:
26-
self.image = image
2722
self.backend = backend
28-
self.cb = cb
23+
self.impl = options["impl"]
24+
self.image = options["ln_image"]
25+
self.cb = options["cb_image"]
26+
self.ln_config = options["ln_config"]
2927
self.ipv4 = generate_ipv4_addr(self.warnet.subnet)
3028
self.rpc_port = 10009
3129

@@ -53,6 +51,7 @@ def get_conf(self, ln_container_name, tank_container_name) -> str:
5351
conf += f" --alias={self.tank.index}"
5452
conf += f" --externalhosts={ln_container_name}"
5553
conf += f" --tlsextradomain={ln_container_name}"
54+
conf += " " + self.ln_config
5655
return conf
5756
return ""
5857

src/warnet/tank.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,13 @@ def parse_graph_node(self, node):
8787

8888
# Special handling for complex properties
8989
if "ln" in node:
90-
impl = node["ln"]
91-
image = node.get("ln-image", None)
92-
cb_image = node.get("ln-cb-image", None)
93-
self.lnnode = LNNode(
94-
self.warnet, self, impl, image, self.warnet.container_interface, cb_image
95-
)
90+
options = {
91+
"impl": node["ln"],
92+
"ln_image": node.get("ln_image", "lightninglabs/lnd:v0.17.0-beta"),
93+
"cb_image": node.get("ln_cb_image", None),
94+
"ln_config": node.get("ln_config", "")
95+
}
96+
self.lnnode = LNNode(self.warnet, self, self.warnet.container_interface, options)
9697

9798
logger.debug(
9899
f"Parsed graph node: {self.index} with attributes: {[f'{key}={value}' for key, value in graph_properties.items()]}"

test/data/ln.graphml

+7-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
<key attr.name="bitcoin_config" attr.type="string" for="node" id="bitcoin_config"/>
44
<key attr.name="tc_netem" attr.type="string" for="node" id="tc_netem"/>
55
<key attr.name="ln" attr.type="string" for="node" id="ln"/>
6-
<key attr.name="ln-image" attr.type="string" for="node" id="ln-image"/>
7-
<key attr.name="ln-cb-image" attr.type="string" for="node" id="ln-cb-image"/>
6+
<key attr.name="ln_image" attr.type="string" for="node" id="ln_image"/>
7+
<key attr.name="ln_cb_image" attr.type="string" for="node" id="ln_cb_image"/>
8+
<key attr.name="ln_config" attr.type="string" for="node" id="ln_config"/>
89
<key attr.name="channel" attr.type="string" for="edge" id="channel"/>
910
<key attr.name="collect_logs" attr.type="boolean" for="node" id="collect_logs"/>
1011
<key attr.name="image" attr.type="string" for="node" id="image"/>
@@ -19,15 +20,16 @@
1920
<data key="version">26.0</data>
2021
<data key="bitcoin_config">-uacomment=w1</data>
2122
<data key="ln">lnd</data>
22-
<data key="ln-image">lightninglabs/lnd:v0.15.5-beta</data>
23-
<data key="ln-cb-image">pinheadmz/circuitbreaker:278737d</data>
23+
<data key="ln_image">lightninglabs/lnd:v0.15.5-beta</data>
24+
<data key="ln_cb_image">pinheadmz/circuitbreaker:278737d</data>
2425
<data key="collect_logs">true</data>
26+
<data key="ln_config">--bitcoin.timelockdelta=20</data>
2527
</node>
2628
<node id="2">
2729
<data key="version">26.0</data>
2830
<data key="bitcoin_config">-uacomment=w2</data>
2931
<data key="ln">lnd</data>
30-
<data key="ln-cb-image">pinheadmz/circuitbreaker:278737d</data>
32+
<data key="ln_cb_image">pinheadmz/circuitbreaker:278737d</data>
3133
</node>
3234
<node id="3">
3335
<data key="version">26.0</data>

test/ln_test.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ def get_cb_forwards(index):
4444
base.warcli("scenarios run ln_init")
4545
base.wait_for_all_scenarios()
4646

47+
print("\nEnsuring channel policy settings")
48+
chans = json.loads(base.warcli("lncli 1 describegraph"))["edges"]
49+
for chan in chans:
50+
# node_1 or node_2 is tank 1 with its non-default --bitcoin.timelockdelta=20
51+
if chan["node1_policy"]["time_lock_delta"] != 20:
52+
assert chan["node2_policy"]["time_lock_delta"] == 20
53+
4754
print("\nEnsuring no circuit breaker forwards yet")
4855
assert len(get_cb_forwards(1)["forwards"]) == 0
4956

@@ -55,17 +62,13 @@ def get_cb_forwards(index):
5562
print(base.warcli(f"lncli 0 payinvoice -f {inv}"))
5663

5764
print("Waiting for payment success")
58-
59-
6065
def check_invoices():
6166
invs = json.loads(base.warcli("lncli 2 listinvoices"))["invoices"]
6267
if len(invs) > 0 and invs[0]["state"] == "SETTLED":
6368
print("\nSettled!")
6469
return True
6570
else:
6671
return False
67-
68-
6972
base.wait_for_predicate(check_invoices)
7073

7174
print("\nEnsuring circuit breaker tracked payment")

0 commit comments

Comments
 (0)