Skip to content

tests: fix flaky test_onchain_rbf_stops_after_confirmation#9348

Open
ksedgwic wants to merge 1 commit into
ElementsProject:masterfrom
ksedgwic:fix-onchain-rbf-unmock-race
Open

tests: fix flaky test_onchain_rbf_stops_after_confirmation#9348
ksedgwic wants to merge 1 commit into
ElementsProject:masterfrom
ksedgwic:fix-onchain-rbf-unmock-race

Conversation

@ksedgwic

Copy link
Copy Markdown
Collaborator

Fixes #9347.

The test censors l2's sendrawtransaction with an rpcproxy mock while the node RBFs its penalty tx three times, then removes the mock so the next RBF version reaches bitcoind for real and gets mined. But each 'RBF onchain txid' log line precedes the corresponding broadcast, so wait_for_log can return -- and the test un-mock -- while the third replacement is still in flight. That older version then lands in bitcoind's real mempool, the next version's broadcast is rejected as a conflict, and the block mines a version the node no longer tracks, so RBF-ing continues after confirmation and the final assertion fails. The full log timeline is in #9347; seen under valgrind, where the window between log line and broadcast is wide.

The fix counts the broadcasts the censoring mock swallows and waits for all four (initial penalty tx plus three replacements) to have reached the proxy before un-mocking, so no broadcast can be in flight when censoring stops.

Verified with three consecutive local runs under valgrind.

The test censors l2's sendrawtransaction with an rpcproxy mock while
the node RBFs its penalty tx three times, then removes the mock so the
next RBF version reaches bitcoind for real and gets mined.  But each
'RBF onchain txid' log line precedes the corresponding broadcast, so
wait_for_log can return -- and the test un-mock -- while the third
replacement is still in flight.  That older version then lands in
bitcoind's real mempool, the next version's broadcast is rejected as a
conflict, and the block mines a version the node no longer tracks, so
RBF-ing continues after confirmation and the final assertion fails.
Seen under valgrind, where the window between log line and broadcast
is wide.

Count the broadcasts the censoring mock swallows and wait for all four
(initial penalty tx plus three replacements) to have reached the proxy
before un-mocking, so no broadcast can be in flight when censoring
stops.

Fixes: ElementsProject#9347
Changelog-None
@ksedgwic
ksedgwic requested a review from enaples July 23, 2026 20:13
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_onchain_rbf_stops_after_confirmation un-mock races the in-flight RBF broadcast

1 participant