Repository navigation
Test that the background received-certificate sync actually repeats - #6837
Merged
Merged
Conversation
ndr-ds
marked this pull request as ready for review
September 18, 2026 01:33
ndr-ds
added a commit
that referenced
this pull request
Sep 18, 2026
…repeats (#6838) 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 @ 4b46d92` with nothing on this branch testing the part that matters: every other listener test here constructs `ChainListener::new(..., false)`, so the loop never runs at all, let alone twice. ## Proposal `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 its only caller is the default `make_chain_client`, and the sync makes exactly one chain client per pass. Two deltas from the `main` version, both mechanical: - conway's `Client::new` takes `requests_scheduler_config` **before** the two cache sizes; `main` takes it last. The cherry-pick carried `main`'s order and did not compile. - conway has no `test_chain_listener_untracks_after_unsubscribe` (#4260 was never backported), so the hunk adding `chain_clients_made` to that test's context was dropped. ## Test Plan ``` $ cargo test --locked -p linera-client --lib chain_listener test result: ok. 7 passed; 0 failed ``` Verified by mutation on this branch, not just inherited from `main`: ``` # background_sync_interval_ms: 0 (pre-#6835 one-shot behaviour) 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 # background_sync_interval_ms: 50 test unit_tests::chain_listener::background_sync_repeats ... ok ``` `cargo clippy -p linera-client --all-targets --all-features` clean; `cargo +nightly-2025-06-10 fmt --all -- --check` clean. ## Release Plan - Nothing to do / backport of an already-released change. Test-only, no production change. ## Links - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist) - Backport of #6837; covers #6835. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.
Motivation
#6830 made the background received-certificate sync repeat on an 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 useChainListenerConfig::default(), which since #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.
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's
timing_sender(). In this crate the only caller oftiming_senderis the defaultmake_chain_client(chain_listener.rs:157; the other call site is the productionClientContext, 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.Test Plan
The assertion is on growth, not on a total, and that distinction was found the hard way. The first version asserted
>= 3chain clients and passed in 0.05 s — including withbackground_sync_interval_ms: 0, i.e. the pre-#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:
Release Plan
testnetbranch.Test-only, no production change. Worth backporting so the conway branch has the same guard.
Links