Skip to content

fix(zaino-state): replace sleep-ordered mines with handshakes in the mempool-stream tests#1377

Open
zancas wants to merge 3 commits into
devfrom
fix_mempool_stream_test_races
Open

fix(zaino-state): replace sleep-ordered mines with handshakes in the mempool-stream tests#1377
zancas wants to merge 3 commits into
devfrom
fix_mempool_stream_test_races

Conversation

@zancas

@zancas zancas commented Jul 7, 2026

Copy link
Copy Markdown
Member

Both mempool-stream mockchain tests ordered "open the stream" before "mine the closing block" with a 500 ms sleep. Under full-suite parallel load the spawned collector can lose that race, and each variant then fails in its own way: the expected-tip variant arms its stream against the post-mine tip and hangs forever awaiting a second mine (observed twice as an indefinite hang of the production suite), while the no-expected-tip variant collects the drained post-mine mempool and fails its assertion on an empty vector (observed once, at 1.8 s, in a parallel run). Neither reproduces solo.

Each test now passes a oneshot handshake: the collector signals after get_mempool_stream returns — the point where the stream's termination condition is locked to the pre-mine tip — and the main task awaits that signal before mining. The ordering becomes deterministic and each test sheds the dead sleep, running about 1.5 s faster. Verified with fifty solo iterations across the two variants and three full parallel runs of the zaino-state binary, all green.

The hangdebug nextest profile that caught the no-expected-tip flake ships alongside the fix. The default profile deliberately runs production unit tests with no slow-timeout, so a hung test pends silently and anonymously; NEXTEST_PROFILE=hangdebug RUST_LOG=trace cargo nextest run names laggards at 60 seconds and terminates a stuck test at 300, dumping its captured output.

🤖 Generated with Claude Code

…mempool-stream tests

Both mempool-stream mockchain tests spawn a collector task whose stream
must open before the main task mines the block that ends the test, and
both enforced that ordering with a 500 ms sleep. Under full-suite
parallel load the collector can lose the race: the expected-tip variant
then arms its stream against the post-mine tip and hangs forever
awaiting a second mine, and the no-expected-tip variant collects the
drained post-mine mempool and fails its assertion on an empty vector.
Both failure modes were observed on loaded machines and neither
reproduces solo.

Each test now passes a oneshot handshake: the collector signals after
get_mempool_stream returns — the point where the stream's termination
condition is locked to the pre-mine tip — and the main task awaits that
signal before mining. The ordering becomes deterministic, and each test
runs about 1.5 s faster by shedding the dead sleep. No fails-before
sibling test accompanies the fix: the race window only opens under
machine load and cannot be made deterministic in a demonstration.

The hangdebug nextest profile that caught the no-expected-tip flake is
committed alongside the fix. The default profile deliberately runs the
production unit tests with no slow-timeout, so a hung test pends
silently and anonymously; a parallel run under this profile names
laggards at 60 seconds and terminates a stuck test at 300, dumping its
captured output.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@zancas
zancas force-pushed the fix_mempool_stream_test_races branch from 43cdd81 to 3c0711f Compare July 9, 2026 20:09
@zancas
zancas requested review from idky137 and nachog00 July 11, 2026 00:04
@zancas
zancas removed the request for review from nachog00 July 17, 2026 15:27
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.

1 participant