From e9b801d9c80a4e67df1ecb7c66467e498ab4c474 Mon Sep 17 00:00:00 2001 From: Michael Schmoock Date: Tue, 7 Sep 2021 11:31:48 +0200 Subject: [PATCH] pyln-client/gossmap: adds testcase for half channels --- .../tests/data/gossip_store.simple.xz | Bin 0 -> 424 bytes contrib/pyln-client/tests/test_gossmap.py | 47 ++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 contrib/pyln-client/tests/data/gossip_store.simple.xz diff --git a/contrib/pyln-client/tests/data/gossip_store.simple.xz b/contrib/pyln-client/tests/data/gossip_store.simple.xz new file mode 100644 index 0000000000000000000000000000000000000000..a8be99deb6ed2737804d807e416b43c7ccce62f2 GIT binary patch literal 424 zcmV;Z0ayP0H+ooF000E$*0e?f03iVu0001VFXf})0{j7JT>u1tFqwm+yt+G>w&oF& z7$22>-U7$nUM<^)^08$7<2nPbX7|7sXHXJ00L}%Gu?Gys+19sCK^2nUIuv^I3Qc)3*{RWsltz6}Hz$D`gpBmo@ zs~795P}=SMslQNbowXb`4Vo$6(v6!;F3h5F^IwBJdoWp(>#{(`+6KF%4@$Up*$D+m zTYDWYdx46V0QLK{!qTp$Dkcs>M-Qj#Ao{g000001X)^Vl*jr2 literal 0 HcmV?d00001 diff --git a/contrib/pyln-client/tests/test_gossmap.py b/contrib/pyln-client/tests/test_gossmap.py index 6591ba976..e83400320 100644 --- a/contrib/pyln-client/tests/test_gossmap.py +++ b/contrib/pyln-client/tests/test_gossmap.py @@ -49,6 +49,53 @@ def test_gossmap(tmp_path): assert channel2.satoshis == 3000000 +def test_gossmap_halfchannel(tmp_path): + """ this test a simple [l1->l2] gossip store that was created by the pyln-testing framework """ + sfile = unxz_data_tmp("gossip_store.simple.xz", tmp_path, "gossip_store", "xb") + g = Gossmap(sfile) + + l1id = "022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59" + l2id = "0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518" + + # check structure parsed correctly + assert(len(g.nodes) == 2) + n1 = g.get_node(l1id) + n2 = g.get_node(l2id) + assert n1 + assert n2 + + chan = g.get_channel("103x1x1") + assert chan + assert chan.node1 == n1 + assert chan.node2 == n2 + + half0 = chan.get_direction(0) + half1 = chan.get_direction(1) + assert half0 + assert half1 + assert half0.direction == 0 + assert half1.direction == 1 + assert half0.channel == chan + assert half1.channel == chan + assert half0.source == n1 + assert half0.destination == n2 + assert half1.source == n2 + assert half1.destination == n1 + + # check metadata + assert half0.timestamp == 1631005020 + assert half1.timestamp == 1631005020 + assert half0.cltv_expiry_delta == 6 + assert half1.cltv_expiry_delta == 6 + assert half0.htlc_minimum_msat == 0 + assert half1.htlc_minimum_msat == 0 + assert half0.htlc_maximum_msat == 990000000 + assert half1.htlc_maximum_msat == 990000000 + assert half0.fee_base_msat == 1 + assert half1.fee_base_msat == 1 + assert half0.fee_proportional_millionths == 10 + + def test_objects(): boltz = "026165850492521f4ac8abd9bd8088123446d126f648ca35e60f88177dc149ceb2" acinq = "03864ef025fde8fb587d989186ce6a4a186895ee44a926bfc370e2c366597a3f8f"