Skip to content

Commit

Permalink
tests: fix flake in test_partial_payment_htlc_loss
Browse files Browse the repository at this point in the history
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 <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Jul 7, 2020
1 parent e12defa commit 3fec96a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -2759,19 +2759,23 @@ 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']

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
Expand Down

0 comments on commit 3fec96a

Please sign in to comment.