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

Function test_reject_invalid_payload

tests/test_pay.py:3451–3478  ·  view source on GitHub ↗

Send an onion payload with an unknown even type. Recipient l2 should reject it the incoming HTLC with an invalid onion payload error.

(node_factory)

Source from the content-addressed store, hash-verified

3449
3450
3451def test_reject_invalid_payload(node_factory):
3452 """Send an onion payload with an unknown even type.
3453
3454 Recipient l2 should reject it the incoming HTLC with an invalid onion
3455 payload error.
3456
3457 """
3458
3459 l1, l2 = node_factory.line_graph(2)
3460 amt = 10**3
3461 route = l1.single_route(l2.info['id'], amt)
3462 inv = l2.rpc.invoice(amt, "lbl", "desc")
3463
3464 first_hop = {'id': route[0]['node_id_out'], 'amount_msat': route[0]['amount_out_msat'], 'delay': route[0]['cltv_out']}
3465
3466 # A TLV payload with an unknown even type:
3467 payload = TlvPayload()
3468 payload.add_field(0xB000, b'Hi there')
3469 hops = [{"pubkey": l2.info['id'], "payload": payload.to_hex()}]
3470 onion = l1.rpc.createonion(hops=hops, assocdata=inv['payment_hash'])
3471 l1.rpc.sendonion(onion=onion['onion'],
3472 first_hop=first_hop,
3473 payment_hash=inv['payment_hash'],
3474 shared_secrets=onion['shared_secrets'])
3475 with pytest.raises(RpcError, match=r'WIRE_INVALID_ONION_PAYLOAD'):
3476 l1.rpc.waitsendpay(inv['payment_hash'])
3477
3478 l2.daemon.wait_for_log(r'Failing HTLC because of an invalid payload')
3479
3480
3481def test_excluded_adjacent_routehint(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 9

add_fieldMethod · 0.95
TlvPayloadClass · 0.90
line_graphMethod · 0.80
single_routeMethod · 0.80
sendonionMethod · 0.80
waitsendpayMethod · 0.80
wait_for_logMethod · 0.80
invoiceMethod · 0.45
to_hexMethod · 0.45

Tested by

no test coverage detected