Skip to content

Commit 253e1d5

Browse files
committed
test: cover simln service with network export on both backends
1 parent afc29c6 commit 253e1d5

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

test/data/ln.graphml

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?><graphml xmlns="http://graphml.graphdrawing.org/xmlns">
22
<key id="version" attr.name="version" attr.type="string" for="node" />
3+
<key id="services" attr.name="services" attr.type="string" for="graph" />
34
<key id="image" attr.name="image" attr.type="string" for="node" />
45
<key id="bitcoin_config" attr.name="bitcoin_config" attr.type="string" for="node" />
56
<key id="tc_netem" attr.name="tc_netem" attr.type="string" for="node" />
@@ -14,6 +15,7 @@
1415
<key id="source_policy" attr.name="source_policy" attr.type="string" for="edge" />
1516
<key id="target_policy" attr.name="target_policy" attr.type="string" for="edge" />
1617
<graph edgedefault="directed">
18+
<data key="services">simln</data>
1719
<node id="0">
1820
<data key="version">26.0</data>
1921
<data key="bitcoin_config">-uacomment=w0</data>

test/data/services.graphml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<data key="version">26.0</data>
2121
<data key="bitcoin_config">-uacomment=w0 -debug=validation</data>
2222
<data key="exporter">true</data>
23+
<data key="ln">lnd</data>
2324
</node>
2425
</graph>
2526
</graphml>

test/ln_test.py

+18-22
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,6 @@ def get_cb_forwards(index):
2525
base.wait_for_all_tanks_status(target="running")
2626
base.wait_for_all_edges()
2727

28-
if base.backend != "compose":
29-
print("\nSkipping network export test, only supported with compose backend")
30-
else:
31-
print("\nTesting warcli network export")
32-
path = Path(base.warcli("network export")) / "sim.json"
33-
with open(path) as file:
34-
data = json.load(file)
35-
print(json.dumps(data, indent=4))
36-
assert len(data["nodes"]) == 3
37-
for node in data["nodes"]:
38-
assert os.path.exists(node["macaroon"])
39-
assert os.path.exists(node["cert"])
40-
41-
4228
print("\nRunning LN Init scenario")
4329
base.warcli("rpc 0 getblockcount")
4430
base.warcli("scenarios run ln_init")
@@ -86,17 +72,27 @@ def check_invoices():
8672
print(base.warcli(f"lncli 2 payinvoice -f {inv}"))
8773

8874
print("Waiting for payment success")
89-
def check_invoices():
90-
invs = json.loads(base.warcli("lncli 0 listinvoices"))["invoices"]
91-
if len(invs) > 0 and invs[0]["state"] == "SETTLED":
92-
print("\nSettled!")
93-
return True
94-
else:
95-
return False
96-
base.wait_for_predicate(check_invoices)
75+
def check_invoices(index):
76+
invs = json.loads(base.warcli(f"lncli {index} listinvoices"))["invoices"]
77+
settled = 0
78+
for inv in invs:
79+
if inv["state"] == "SETTLED":
80+
settled += 1
81+
return settled
82+
base.wait_for_predicate(lambda: check_invoices(0) == 1)
9783

9884
print("\nEnsuring channel-level channel policy settings: target")
9985
payment = json.loads(base.warcli("lncli 2 listpayments"))["payments"][0]
10086
assert payment["fee_msat"] == "2213"
10187

88+
print("\nEngaging simln")
89+
activity = [{
90+
"source": "ln-0",
91+
"destination": chan["node1_pub"],
92+
"interval_secs": 1,
93+
"amount_msat": 2000
94+
}]
95+
base.warcli(f"network export --activity={json.dumps(activity).replace(' ', '')}")
96+
base.wait_for_predicate(lambda: check_invoices(0) > 1 or check_invoices(1) > 1 or check_invoices(2) > 1)
97+
10298
base.stop_server()

0 commit comments

Comments
 (0)