From 3fec96a7b12fdf713f67c1a5925b427c0e5bd26e Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 2 Jul 2020 13:53:50 +0930 Subject: [PATCH] tests: fix flake in test_partial_payment_htlc_loss Make sure we've actually confirmed the HTLC; if it's not confirmed yet then we won't fast-fail it, and we'll timeout instead: ``` > l1.rpc.waitsendpay(payment_hash=inv['payment_hash'], timeout=TIMEOUT, partid=1) E AssertionError: Pattern 'WIRE_PERMANENT_CHANNEL_FAILURE \\(reply from remote\\)' not found in "RPC call failed: method: waitsendpay, payload: {'payment_hash': 'c186643391469aa8190415496c85b1eb789cb2b756a76d4c9ce21dd34c698d92', 'timeout': 30, 'partid': 1}, error: {'code': 200, 'message': 'Timed out while waiting'}" ``` Signed-off-by: Rusty Russell --- tests/test_pay.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/test_pay.py b/tests/test_pay.py index f0d8427ce..a064f9be5 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -2759,10 +2759,14 @@ def test_partial_payment_restart(node_factory, bitcoind): l1.rpc.waitsendpay(payment_hash=inv['payment_hash'], timeout=TIMEOUT, partid=2) -@unittest.skipIf(not DEVELOPER, "needs dev-fail") +@unittest.skipIf(not DEVELOPER, "needs dev-disconnect") def test_partial_payment_htlc_loss(node_factory, bitcoind): """Test that we discard a set when the HTLC is lost""" - l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True) + # We want l2 to fail once it has completed first htlc. + l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True, + opts=[{}, + {'disconnect': ['=WIRE_UPDATE_ADD_HTLC', '+WIRE_REVOKE_AND_ACK']}, + {}]) inv = l3.rpc.invoice(1000, 'inv', 'inv') paysecret = l3.rpc.decodepay(inv['bolt11'])['payment_secret'] @@ -2770,8 +2774,8 @@ def test_partial_payment_htlc_loss(node_factory, bitcoind): route = l1.rpc.getroute(l3.info['id'], 500, 1)['route'] l1.rpc.sendpay(route=route, payment_hash=inv['payment_hash'], msatoshi=1000, bolt11=inv['bolt11'], payment_secret=paysecret, partid=1) - wait_for(lambda: [f['status'] for f in l2.rpc.listforwards()['forwards']] == ['offered']) + wait_for(lambda: not only_one(l2.rpc.listpeers(l3.info['id'])['peers'])['connected']) l2.rpc.dev_fail(l3.info['id']) # Since HTLC is missing from commit (dust), it's closed as soon as l2 sees