Skip to content

Fix flaky async_payment test due to non-deterministic event ordering#799

Merged
tnull merged 1 commit intolightningdevkit:mainfrom
joostjager:fix-async-payment-test
Feb 20, 2026
Merged

Fix flaky async_payment test due to non-deterministic event ordering#799
tnull merged 1 commit intolightningdevkit:mainfrom
joostjager:fix-async-payment-test

Conversation

@joostjager
Copy link
Contributor

node_sender_lsp and node_receiver_lsp each have two channels, so they receive two ChannelReady events whose order depends on timing. The test previously consumed these events in a fixed order, which could fail when the events arrive in the opposite order.

Reproduced locally by swapping the assertion order at line 1346-1347, which fails deterministically since the "normal" local ordering is the opposite of the one expected by the swapped assertions.

Add an expect_channel_ready_events! macro that consumes two ChannelReady events and asserts both expected counterparties are present regardless of arrival order.

Fixes #798

node_sender_lsp and node_receiver_lsp each have two channels, so they
receive two ChannelReady events whose order depends on timing. The test
previously consumed these events in a fixed order, which could fail when
the events arrive in the opposite order.

Reproduced locally by swapping the assertion order at line 1346-1347,
which fails deterministically since the "normal" local ordering is the
opposite of the one expected by the swapped assertions.

Add an expect_channel_ready_events\! macro that consumes two ChannelReady
events and asserts both expected counterparties are present regardless of
arrival order.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Feb 20, 2026

👋 Thanks for assigning @tnull as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@joostjager joostjager requested a review from tnull February 20, 2026 13:59
Copy link
Collaborator

@tnull tnull left a comment

Choose a reason for hiding this comment

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

Thanks!


pub(crate) use expect_channel_ready_event;

macro_rules! expect_channel_ready_events {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Could have named it expect_two_channel_ready_events.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, would've been better

@tnull tnull merged commit 9e0cfc5 into lightningdevkit:main Feb 20, 2026
17 of 18 checks passed
@joostjager joostjager self-assigned this Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

async_payment test is flaky

3 participants