Skip to content

Commit 6b76a15

Browse files
committed
test: import graph
1 parent 677e68f commit 6b76a15

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

Diff for: test/graph_test.py

+19-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#!/usr/bin/env python3
22

3+
import json
34
import os
45
import tempfile
56
import uuid
67
from pathlib import Path
7-
8+
from warnet.utils import channel_match
89
from test_base import TestBase
9-
from warnet.utils import DEFAULT_TAG
1010

11-
json_file_path = Path(os.path.dirname(__file__)) / "data" / "LN_10.json"
1211

1312
base = TestBase()
1413
base.start_server()
@@ -41,6 +40,10 @@
4140
base.wait_for_all_tanks_status(target="stopped")
4241

4342
print("Import graph")
43+
44+
json_file_path = Path(os.path.dirname(__file__)) / "data" / "LN_10.json"
45+
NUM_NODES = 10
46+
4447
with tempfile.TemporaryDirectory() as dir:
4548
tf = f"{dir}/{str(uuid.uuid4())}.graphml"
4649
if base.backend == "compose":
@@ -66,6 +69,18 @@
6669
base.warcli("scenarios run ln_init")
6770
base.wait_for_all_scenarios()
6871

69-
print(base.warcli("lncli 0 describegraph"))
72+
print("Ensuring warnet LN channel policies match imported JSON description")
73+
with open(json_file_path, "r") as file:
74+
actual = json.loads(base.warcli(f"lncli 0 describegraph"))["edges"]
75+
expected = json.loads(file.read())["edges"]
76+
expected = sorted(expected, key=lambda chan: int(chan['channel_id']))
77+
for chan_index, actual_chan in enumerate(actual):
78+
expected_chan = expected[chan_index]
79+
if not channel_match(actual_chan, expected_chan, allow_flip=True):
80+
raise Exception(
81+
f"Channel policy doesn't match source: {actual_chan['channel_id']}\n" +
82+
"Actual:\n" + json.dumps(actual_chan, indent=2) +
83+
"Expected:\n" + json.dumps(expected_chan, indent=2)
84+
)
7085

7186
base.stop_server()

0 commit comments

Comments
 (0)