Test keysend description handling near BOLT11 field size limits. Checks boundary conditions where the payload length is just below, exactly at, and just above the maximum allowed tagged-field size. See common/bolt11.h: BOLT11_FIELD_BYTE_LIMIT.
(node_factory, keysendcmd)
| 3776 | |
| 3777 | @pytest.mark.parametrize("keysendcmd", ["keysend", "xkeysend"]) |
| 3778 | def test_keysend_description_size_limit(node_factory, keysendcmd): |
| 3779 | """ |
| 3780 | Test keysend description handling near BOLT11 field size limits. |
| 3781 | |
| 3782 | Checks boundary conditions where the payload length is just below, |
| 3783 | exactly at, and just above the maximum allowed tagged-field size. |
| 3784 | |
| 3785 | See common/bolt11.h: BOLT11_FIELD_BYTE_LIMIT. |
| 3786 | """ |
| 3787 | if keysendcmd == 'keysend': |
| 3788 | opts = {'allow-deprecated-apis': True} |
| 3789 | else: |
| 3790 | opts = {} |
| 3791 | l1, l2 = node_factory.line_graph(2, wait_for_announce=True, opts=opts) |
| 3792 | amt = 10000 |
| 3793 | prefix = 'keysend: ' |
| 3794 | base_len = len(prefix) |
| 3795 | |
| 3796 | if keysendcmd == 'xkeysend': |
| 3797 | l1keysend = l1.rpc.xkeysend |
| 3798 | else: |
| 3799 | l1keysend = l1.rpc.keysend |
| 3800 | |
| 3801 | tlv_lens = [638, 639, 640, 641, 1022, 1023, 1024] |
| 3802 | expected = set() |
| 3803 | for tlv_payload_length in tlv_lens: |
| 3804 | # Prep TLV payload with test length |
| 3805 | body_len = tlv_payload_length - base_len |
| 3806 | tlv_payload = ("a" * body_len).encode().hex() |
| 3807 | expected.add(prefix + "a" * body_len) |
| 3808 | |
| 3809 | # Send keysend payment with test payload |
| 3810 | l1keysend(l2.info["id"], amt, extratlvs={7629169: tlv_payload}) |
| 3811 | |
| 3812 | assert set(inv['description'] for inv in l2.rpc.listinvoices()["invoices"]) == expected |
| 3813 | assert all(inv['amount_received_msat'] == amt for inv in l2.rpc.listinvoices()["invoices"]) |
| 3814 | |
| 3815 | |
| 3816 | def test_invalid_onion_channel_update(node_factory): |
nothing calls this directly
no test coverage detected