tests: fix flake in test_dataloss_protection - #9520
Merged
daywalker90 merged 1 commit intoSep 18, 2026
Merged
daywalker90 merged 1 commit into
daywalker90 merged 1 commit into
Conversation
Andezion
reviewed
Sep 16, 2026
| except TimeoutError: | ||
| if l1.is_connected(l2): | ||
| l1.rpc.disconnect(l2.info['id'], force=True) | ||
| l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
Collaborator
There was a problem hiding this comment.
maybe we should check the real connected field, matching the existing convention already used elsewhere in this same file (tests/test_connection.py at line 1374 - wait_for(lambda: not only_one(l1.rpc.listpeers()['peers'])['connected'])), so we can have something like:
peer = only_one(l1.rpc.listpeers(l2.info['id'])['peers'])
if peer['connected']:
l1.rpc.disconnect(l2.info['id'], force=True)
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
or!! just try the disconnect and ignore "not connected" errors, since connect() afterwards is what actually matters, because from what i see now we are checking whether the peer appears in listpeers, not whether it is actually connected
l2 detects the data loss and sends l1 an "Awaiting unilateral close"
error (after the channeld's 1 second delay), which l1 must receive to
drop to chain. But l1's channeld normally sends a warning and exits
first; if l2's error arrives before l1's connectd has torn that subd
down it is routed to the dying channeld and lost, so l1 never sees it
and we time out waiting for:
l1.daemon.wait_for_log("They sent ERROR.*Awaiting unilateral close")
Reconnect if we don't see it: channel->error is resent when the peer
reconnects, so l1 gets the error and drops to chain. We may already be
disconnected, in which case disconnect() fails with "Peer not
connected": that's fine, connect() is what matters.
This restores the workaround the test had before 6fdaec3 replaced it
with the channeld sleep.
Changelog-None
daywalker90
force-pushed
the
fix-test-dataloss-protection-flake
branch
from
September 17, 2026 11:17
592b770 to
aa95a39
Compare
Andezion
approved these changes
Sep 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
l2 detects the data loss and sends l1 an "Awaiting unilateral close" error (after the channeld's 1 second delay), which l1 must receive to drop to chain. But l1's channeld normally sends a warning and exits first; if l2's error arrives before l1's connectd has torn that subd down it is routed to the dying channeld and lost, so l1 never sees it and we time out waiting for:
l1.daemon.wait_for_log("They sent ERROR.*Awaiting unilateral close")
Reconnect if we don't see it: channel->error is resent when the peer reconnects, so l1 gets the error and drops to chain. This restores the workaround the test had before 6fdaec3 replaced it with the channeld sleep.
Changelog-None
Fixes: #9519
Not sure if this should be fixed in code instead?