Tests wether we are able to pay through parallel channels concurrently. To do that we need to enable strict-forwarding.
(node_factory, bitcoind)
| 6897 | |
| 6898 | |
| 6899 | def 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}, |
nothing calls this directly
no test coverage detected