Skip to content

tests: fix flake in test_dataloss_protection - #9520

Merged
daywalker90 merged 1 commit into
ElementsProject:masterfrom
daywalker90:fix-test-dataloss-protection-flake
Sep 18, 2026
Merged

daywalker90 merged 1 commit into
ElementsProject:masterfrom
daywalker90:fix-test-dataloss-protection-flake

Conversation

@daywalker90

Copy link
Copy Markdown
Collaborator

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?

Comment thread tests/test_connection.py
except TimeoutError:
if l1.is_connected(l2):
l1.rpc.disconnect(l2.info['id'], force=True)
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
daywalker90 force-pushed the fix-test-dataloss-protection-flake branch from 592b770 to aa95a39 Compare September 17, 2026 11:17
@daywalker90
daywalker90 merged commit 946f700 into ElementsProject:master Sep 18, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI flake test_dataloss_protection

2 participants