Skip to content

pyln-testing: don't let wait_for_log match its own forwarded announcement#9344

Open
ksedgwic wants to merge 1 commit into
ElementsProject:masterfrom
ksedgwic:fix-inline-plugin-log-selfmatch
Open

pyln-testing: don't let wait_for_log match its own forwarded announcement#9344
ksedgwic wants to merge 1 commit into
ElementsProject:masterfrom
ksedgwic:fix-inline-plugin-log-selfmatch

Conversation

@ksedgwic

Copy link
Copy Markdown
Collaborator

Fixes #9343.

An inline plugin's Plugin() lives in the test process, and Plugin() installs a PluginLogHandler on the root logger so a plugin author's logging calls reach lightningd. In the test process that handler also forwards pyln's own machinery logs into the node's log whenever the test-side logger emits at DEBUG. wait_for_logs() announces Waiting for [pattern] with the pattern embedded verbatim, so the announcement lands in the very log being scanned and matches itself - the wait silently becomes a no-op. That is what let test_sendpay_notifications_nowaiter race its channel close against the first payment (assert 0 == 1); any literal-pattern wait_for_log on an inline-plugin node is similarly voided under DEBUG logging, which can mask races in tests that currently pass.

The fix attaches a filter to the inline plugin's log handler that only forwards records originating outside the pyln packages: author logging still reaches the node log, pyln internals never do.

The new test proves both directions and reproduces the bug deterministically: before the fix it fails with DID NOT RAISE TimeoutError (the sentinel wait matched its own announcement); after it, an author-logged marker is still found while the never-logged sentinel genuinely times out.

…ment

An inline plugin's Plugin() object lives in the test process, and
Plugin() installs a PluginLogHandler on the root logger so that a
plugin author's `logging` calls reach lightningd.  In the test process
that handler also forwards pyln's own machinery logs into the node's
log whenever the test-side logger emits at DEBUG.  In particular
wait_for_logs() announces 'Waiting for [pattern]' with the pattern
embedded verbatim, so the announcement lands in the very log being
scanned and matches itself, silently reducing the wait to a no-op.
That let test_sendpay_notifications_nowaiter race its channel close
against the first payment (both payments then fail and the success
assertion sees an empty list); any literal-pattern wait_for_log on an
inline-plugin node is similarly voided under DEBUG logging.

Attach a filter to the inline plugin's log handler that only forwards
records originating outside the pyln packages, so author logging still
reaches the node log but pyln internals never do.

The new test covers both directions: an author log line is found by
wait_for_log, and a never-logged sentinel genuinely times out (it
matched instantly via the forwarded announcement before this fix).

Fixes: ElementsProject#9343
Changelog-None
@ksedgwic
ksedgwic requested a review from cdecker as a code owner July 21, 2026 22:41
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.

Flaky test_sendpay_notifications_nowaiter: wait_for_log self-matches its own forwarded announcement on inline-plugin nodes

1 participant