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

Function test_keysend_routehint

tests/test_pay.py:3644–3688  ·  view source on GitHub ↗

Test whether we can deliver a keysend by adding a routehint on the cli

(node_factory)

Source from the content-addressed store, hash-verified

3642
3643
3644def test_keysend_routehint(node_factory):
3645 """Test whether we can deliver a keysend by adding a routehint on the cli
3646 """
3647 amt = 10000
3648 l1, l2 = node_factory.line_graph(2, wait_for_announce=True, opts={'allow-deprecated-apis': True})
3649 l3 = node_factory.get_node()
3650 l2.connect(l3)
3651 l2.fundchannel(l3, announce_channel=False)
3652
3653 dest = l3.info['id']
3654 routehints = [
3655 [
3656 {
3657 'scid': only_one(l3.rpc.listpeerchannels()['channels'])['alias']['remote'],
3658 'id': l2.info['id'],
3659 'feebase': '1msat',
3660 'feeprop': 10,
3661 'expirydelta': 9,
3662 }
3663 ],
3664 [ # Dummy
3665 {
3666 'scid': '1x2x3',
3667 'id': '02' * 33,
3668 'feebase': 1,
3669 'feeprop': 1,
3670 'expirydelta': 9,
3671 },
3672 ],
3673 ]
3674
3675 # Without any hints we should fail:
3676 with pytest.raises(RpcError):
3677 l1.rpc.call("keysend", payload={'destination': dest, 'amount_msat': amt})
3678
3679 # We should also fail with only non-working hints:
3680 with pytest.raises(RpcError):
3681 l1.rpc.call("keysend", payload={'destination': dest, 'amount_msat': amt, 'routehints': routehints[1:]})
3682
3683 l1.rpc.call("keysend", payload={'destination': dest, 'amount_msat': amt, 'routehints': routehints})
3684 invs = l3.rpc.listinvoices()['invoices']
3685 assert(len(invs) == 1)
3686
3687 inv = invs[0]
3688 assert(inv['amount_received_msat'] >= Millisatoshi(amt))
3689
3690
3691def test_xkeysend_layer(node_factory):

Callers

nothing calls this directly

Calls 9

only_oneFunction · 0.90
MillisatoshiClass · 0.90
line_graphMethod · 0.80
listpeerchannelsMethod · 0.80
get_nodeMethod · 0.45
connectMethod · 0.45
fundchannelMethod · 0.45
callMethod · 0.45
listinvoicesMethod · 0.45

Tested by

no test coverage detected