Skip to content

Commit 6c7c78e

Browse files
committed
pytest: test for crashing with HTLC added tlvs.
Reported-by: grubles Signed-off-by: Rusty Russell <[email protected]>
1 parent 1c537c2 commit 6c7c78e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/test_pay.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7014,3 +7014,37 @@ def pay_with_sendonion(invoice, route, groupid, partid):
70147014
invoice = only_one(l3.rpc.listinvoices("inv")["invoices"])
70157015
# the receive amount should be exact
70167016
assert invoice["amount_received_msat"] == Millisatoshi(total_amount)
7017+
7018+
7019+
@pytest.mark.xfail(strict=True)
7020+
def test_htlc_tlv_crash(node_factory):
7021+
"""Marshalling code treated an array of htlc_added as if they were tal objects, but only the head is a tal object so if we have more than one, BOOM!"""
7022+
plugin = os.path.join(os.path.dirname(__file__), 'plugins/htlc_accepted-customtlv.py')
7023+
# To crash, we need TWO added htlcs at once. Try to force batching!
7024+
l1, l2, l3 = node_factory.line_graph(3, opts=[{},
7025+
{'commit-time': 10000, 'plugin': plugin},
7026+
{'plugin': plugin}],
7027+
wait_for_announce=True)
7028+
7029+
single_tlv = "fe00010001012a" # represents type: 65537, lenght: 1, value: 42
7030+
l2.rpc.setcustomtlvs(tlvs=single_tlv)
7031+
7032+
route = [{'amount_msat': 101,
7033+
'id': l2.info['id'],
7034+
'delay': 16,
7035+
'channel': first_scid(l1, l2),
7036+
},
7037+
{'amount_msat': 100,
7038+
'id': l3.info['id'],
7039+
'delay': 10,
7040+
'channel': first_scid(l2, l3)
7041+
}]
7042+
7043+
# Amount must be nonzero!
7044+
inv1 = l3.rpc.invoice(100, "inv1", "inv1")
7045+
inv2 = l3.rpc.invoice(100, "inv2", "inv2")
7046+
l1.rpc.sendpay(route, inv1['payment_hash'], payment_secret=inv1['payment_secret'])
7047+
l1.rpc.sendpay(route, inv2['payment_hash'], payment_secret=inv2['payment_secret'])
7048+
7049+
l1.rpc.waitsendpay(inv1['payment_hash'], TIMEOUT)
7050+
l1.rpc.waitsendpay(inv2['payment_hash'], TIMEOUT)

0 commit comments

Comments
 (0)