Repository navigation
[conway] Test that the background received-certificate sync actually repeats - #6838
Merged
ndr-ds merged 1 commit intoSep 18, 2026
Conversation
…inera-io#6837) interval, because that sync is the only thing that advances the per-validator trackers — without it, every process restart walks the entire backlog accumulated since the previous restart (3.8M log entries on one live chain, saturating validator storage for the length of the walk). Nothing tests the part that matters. Every listener test in the file constructs `ChainListener::new(..., false)` — background sync **disabled** — so the loop never runs at all, let alone twice. And the tests that do build a config use `ChainListenerConfig::default()`, which since linera-io#6830 means a 15-minute interval, so even if one enabled the sync it would only ever observe the first pass. The behaviour change is therefore entirely unexercised: reviewed by reading, never run. `background_sync_repeats` starts a listener with background sync **enabled** and a 50 ms interval, and asserts the sync keeps running. Counting is done by incrementing a counter in the test context's `timing_sender()`. In this crate the only caller of `timing_sender` is the default `make_chain_client` (`chain_listener.rs:157`; the other call site is the production `ClientContext`, not this test double), and the sync makes exactly one chain client per pass — so the counter counts passes without duplicating any production logic in the test double. If that coupling ever breaks the counter stops rising and the test fails; it cannot silently pass. ``` $ cargo test -p linera-client --lib chain_listener test result: ok. 8 passed; 0 failed ``` **The assertion is on growth, not on a total, and that distinction was found the hard way.** The first version asserted `>= 3` chain clients and passed in 0.05 s — including with `background_sync_interval_ms: 0`, i.e. the pre-linera-io#6830 one-shot behaviour. Startup makes exactly 3 chain clients on its own, so any fixed threshold is met without the loop ever repeating: a tautology. The test now lets startup settle, records that baseline, and requires the count to climb by 2 more. Verified by mutation: ``` test unit_tests::chain_listener::background_sync_repeats ... FAILED Error: background sync did not repeat: 3 chain clients made, still at the 3 from startup test unit_tests::chain_listener::background_sync_repeats ... ok ``` - These changes should be backported to the latest `testnet` branch. Test-only, no production change. Worth backporting so the conway branch has the same guard. - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist) - Covers linera-io#6830 (backported as linera-io#6835), which is being deployed to the PM workers. (cherry picked from commit 672d97b)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #6837 to
testnet_conway.Motivation
#6835 (the conway backport of #6830) made the background received-certificate sync repeat on an interval, because that sync is the only thing that advances the per-validator trackers. It shipped to the PM workers in
linera-client @ 4b46d92with nothing on this branch testing the part that matters: every other listener test here constructsChainListener::new(..., false), so the loop never runs at all, let alone twice.Proposal
background_sync_repeatsstarts a listener with background sync enabled and a 50 ms interval, and asserts the sync keeps running. Counting is done by incrementing a counter in the test context'stiming_sender()— in this crate its only caller is the defaultmake_chain_client, and the sync makes exactly one chain client per pass.Two deltas from the
mainversion, both mechanical:Client::newtakesrequests_scheduler_configbefore the two cache sizes;maintakes it last. The cherry-pick carriedmain's order and did not compile.test_chain_listener_untracks_after_unsubscribe(Stop tracking chains after unsubscribing. (If that was the only reason for tracking.) #4260 was never backported), so the hunk addingchain_clients_madeto that test's context was dropped.Test Plan
Verified by mutation on this branch, not just inherited from
main:cargo clippy -p linera-client --all-targets --all-featuresclean;cargo +nightly-2025-06-10 fmt --all -- --checkclean.Release Plan
Test-only, no production change.
Links
🤖 Generated with Claude Code