MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_parallel_channels_reserve

Function test_parallel_channels_reserve

tests/test_pay.py:6899–7004  ·  view source on GitHub ↗

Tests wether we are able to pay through parallel channels concurrently. To do that we need to enable strict-forwarding.

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

6897
6898
6899def test_parallel_channels_reserve(node_factory, bitcoind):
6900 """Tests wether we are able to pay through parallel channels concurrently.
6901 To do that we need to enable strict-forwarding."""
6902
6903 def direction(node1, node2):
6904 return 0 if node1.info["id"] < node2.info["id"] else 1
6905
6906 def get_local_channel_by_id(node, chanid):
6907 peerchannels = node.rpc.listpeerchannels()["channels"]
6908 if not peerchannels:
6909 return None
6910 for c in peerchannels:
6911 if c["channel_id"] == chanid:
6912 return c
6913 return None
6914
6915 opts = {
6916 "fee-base": 0,
6917 "fee-per-satoshi": 0,
6918 "cltv-delta": 6,
6919 "dev-strict-forwarding": None,
6920 }
6921 l1, l2, l3 = node_factory.get_nodes(3, opts=opts)
6922
6923 l1.fundwallet(10**7)
6924 l2.fundwallet(10**7)
6925
6926 scids = []
6927
6928 l1.rpc.connect(l2.info["id"], "localhost", l2.port)
6929 l2.rpc.connect(l3.info["id"], "localhost", l3.port)
6930
6931 c12 = l1.rpc.fundchannel(l2.info["id"], 3000_000, minconf=0)["channel_id"]
6932
6933 c23 = []
6934 c23.append(l2.rpc.fundchannel(l3.info["id"], 1000_000, minconf=0)["channel_id"])
6935 c23.append(l2.rpc.fundchannel(l3.info["id"], 2000_000, minconf=0)["channel_id"])
6936
6937 bitcoind.generate_block(6)
6938 sync_blockheight(bitcoind, [l1, l2, l3])
6939
6940 scids.append(get_local_channel_by_id(l1, c12)["short_channel_id"])
6941 scids.append(get_local_channel_by_id(l2, c23[0])["short_channel_id"])
6942 scids.append(get_local_channel_by_id(l2, c23[1])["short_channel_id"])
6943
6944 for l in [l1, l2, l3]:
6945 for c in scids:
6946 l.wait_channel_active(c)
6947
6948 # we should be able to send these two parts:
6949 nparts = 2
6950 route_amounts = ["750000sat", "1750000sat"]
6951 total_msat = sum([Millisatoshi(a) for a in route_amounts[:nparts]])
6952
6953 # Test succeeds if we are able to pay this invoice
6954 inv = l3.rpc.call(
6955 "invoice",
6956 {"amount_msat": total_msat, "label": "inv", "description": "inv", "cltv": 10},

Callers

nothing calls this directly

Calls 14

sync_blockheightFunction · 0.90
MillisatoshiClass · 0.90
only_oneFunction · 0.90
get_local_channel_by_idFunction · 0.85
get_nodesMethod · 0.80
fundwalletMethod · 0.80
generate_blockMethod · 0.80
wait_channel_activeMethod · 0.80
wait_for_htlcsMethod · 0.80
directionFunction · 0.70
connectMethod · 0.45
fundchannelMethod · 0.45

Tested by

no test coverage detected