paytest: Reproduce crash reported by m-schmoock on direct payment

We crash the plugin accidentally if we're not handling a paytest but
rather a payment destined for us, due to us falsely assuming the
short-channel-id to be set in the onion

Reported-by: Michael Schmoock <@m-schmoock>
This commit is contained in:
Christian Decker
2021-03-25 14:39:37 +01:00
committed by Michael Schmoock
parent 281e56a5ab
commit fb77c4989b

View File

@@ -43,9 +43,6 @@ def test_mpp_pay(node_factory):
l1, l2 = node_factory.line_graph(2, opts=pluginopt, wait_for_announce=True) l1, l2 = node_factory.line_graph(2, opts=pluginopt, wait_for_announce=True)
res = l1.rpc.paytest(l2.info['id'], 10**8) res = l1.rpc.paytest(l2.info['id'], 10**8)
from pprint import pprint
#pprint(res)
l2.daemon.wait_for_log(r'Received 100000000/100000000 with [0-9]+ parts') l2.daemon.wait_for_log(r'Received 100000000/100000000 with [0-9]+ parts')
parts = res['status']['attempts'] parts = res['status']['attempts']
@@ -58,3 +55,18 @@ def test_mpp_pay(node_factory):
is16399 = [p == 16399 for p in outcomes] is16399 = [p == 16399 for p in outcomes]
assert all(is16399) assert all(is16399)
assert len(is16399) >= 1 assert len(is16399) >= 1
@pytest.mark.xfail(strict=True)
def test_incoming_payment(node_factory):
"""Ensure that we don't fail if the payment is not a paytest.
"""
l1, l2 = node_factory.line_graph(2, opts=pluginopt, wait_for_announce=True)
inv = l2.rpc.invoice(42, 'lbl', 'desc')['bolt11']
l1.rpc.pay(inv)
plugins = [p['name'] for p in l2.rpc.listconfigs()['plugins']]
assert 'paytest.py' in plugins
plugins = [p['name'] for p in l1.rpc.listconfigs()['plugins']]
assert 'paytest.py' in plugins