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)
| 3449 | |
| 3450 | |
| 3451 | def 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 | |
| 3481 | def test_excluded_adjacent_routehint(node_factory, bitcoind): |
nothing calls this directly
no test coverage detected