If we have a direct channel to the destination we should use that. This is complicated a bit by not having sufficient capacity, but the channel_hints can help us there. l1 -> l2 | ^ v / l3
(node_factory, bitcoind)
| 3878 | |
| 3879 | |
| 3880 | def test_pay_peer(node_factory, bitcoind): |
| 3881 | """If we have a direct channel to the destination we should use that. |
| 3882 | |
| 3883 | This is complicated a bit by not having sufficient capacity, but the |
| 3884 | channel_hints can help us there. |
| 3885 | |
| 3886 | l1 -> l2 |
| 3887 | | ^ |
| 3888 | v / |
| 3889 | l3 |
| 3890 | """ |
| 3891 | # Set the dust exposure higher, this gets triggered on liquid |
| 3892 | l1, l2, l3 = node_factory.get_nodes(3, opts={'max-dust-htlc-exposure-msat': '100000sat'}) |
| 3893 | node_factory.join_nodes([l1, l2]) |
| 3894 | node_factory.join_nodes([l1, l3]) |
| 3895 | node_factory.join_nodes([l3, l2], wait_for_announce=True) |
| 3896 | |
| 3897 | wait_for(lambda: len(l1.rpc.listchannels()['channels']) == 6) |
| 3898 | |
| 3899 | def spendable(n1, n2): |
| 3900 | chan = n1.rpc.listpeerchannels(n2.info['id'])['channels'][0] |
| 3901 | avail = chan['spendable_msat'] |
| 3902 | return Millisatoshi(avail) |
| 3903 | |
| 3904 | amt = Millisatoshi(10**8) |
| 3905 | # How many payments do we expect to go through directly? |
| 3906 | direct = spendable(l1, l2) // amt |
| 3907 | |
| 3908 | # Remember the l1 -> l3 capacity, it should not change until we run out of |
| 3909 | # direct capacity. |
| 3910 | l1l3cap = spendable(l1, l3) |
| 3911 | |
| 3912 | for i in range(0, direct): |
| 3913 | inv = l2.rpc.invoice(amt.millisatoshis, "lbl{}".format(i), |
| 3914 | "desc{}".format(i))['bolt11'] |
| 3915 | l1.dev_pay(inv, dev_use_shadow=False) |
| 3916 | |
| 3917 | # We should not have more than amt in the direct channel anymore |
| 3918 | assert(spendable(l1, l2) < amt) |
| 3919 | assert(spendable(l1, l3) == l1l3cap) |
| 3920 | |
| 3921 | # Next one should take the alternative, but it should still work |
| 3922 | inv = l2.rpc.invoice(amt.millisatoshis, "final", "final")['bolt11'] |
| 3923 | l1.dev_pay(inv, dev_use_shadow=False) |
| 3924 | |
| 3925 | |
| 3926 | def test_mpp_adaptive(node_factory, bitcoind): |
nothing calls this directly
no test coverage detected