Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4412,9 +4412,20 @@ def capture(message, **kwargs):

fut = executor.submit(run_graceful)

inotif = 0

# Wait until graceful has sent at least one HTLC expiry notification
wait_for(lambda: len(notifications) == 1)
wait_for(lambda: notifications[0] == f'Next HTLC SENT_ADD_ACK_REVOCATION expires at block #118 (10 blocks from now) going to peer {l3.info["id"]} (connected)')
wait_for(lambda: len(notifications) >= inotif + 1)

# Depending on on timing between the sendpay and `l2.rpc.graceful`, we may get
# RCVD_ADD_REVOCATION or we may be too late to get that.
if notifications[inotif] == f'Next HTLC RCVD_ADD_REVOCATION expires at block #118 (10 blocks from now) going to peer {l3.info["id"]} (connected)':
# If we get RCVD_ADD_REVOCATION, ignore it and move onto the next notification
inotif += 1
Comment thread
ddustin marked this conversation as resolved.
wait_for(lambda: len(notifications) >= inotif + 1)

wait_for(lambda: notifications[inotif] == f'Next HTLC SENT_ADD_ACK_REVOCATION expires at block #118 (10 blocks from now) going to peer {l3.info["id"]} (connected)')
inotif += 1

# This will tell us about htlcs and the peers (peers unordered)
ret = l2.rpc.graceful(1)
Expand All @@ -4425,12 +4436,16 @@ def capture(message, **kwargs):

# Close incoming connection, so incoming HTLC gets stuck.
l1.rpc.disconnect(l2.info['id'], force=True)
wait_for(lambda: notifications[-1] == f'Next HTLC SENT_ADD_ACK_REVOCATION expires at block #118 (10 blocks from now) going to peer {l3.info["id"]} (connected)')
wait_for(lambda: len(notifications) >= inotif + 1)
wait_for(lambda: notifications[inotif] == f'Next HTLC SENT_ADD_ACK_REVOCATION expires at block #118 (10 blocks from now) going to peer {l3.info["id"]} (connected)')
inotif += 1

# Release the hold so the *outgoing* HTLC resolves
open(os.path.join(l3.daemon.lightning_dir, TEST_NETWORK, "unhold"), "w").close()

wait_for(lambda: notifications[-1] == f'Next HTLC SENT_REMOVE_HTLC expires at block #124 (16 blocks from now) coming from peer {l1.info["id"]} (disconnected)')
wait_for(lambda: len(notifications) >= inotif + 1)
wait_for(lambda: notifications[inotif] == f'Next HTLC SENT_REMOVE_HTLC expires at block #124 (16 blocks from now) coming from peer {l1.info["id"]} (disconnected)')
inotif += 1

ret = l2.rpc.graceful(1)
assert ret == {'pending_htlc_expiries': [124]}
Expand Down
Loading