Skip to content

[conway] Test that the background received-certificate sync actually repeats - #6838

Merged
ndr-ds merged 1 commit into
linera-io:testnet_conwayfrom
ndr-ds:ndr-ds/backport-sync-repeat-test-conway
Sep 18, 2026
Merged

ndr-ds merged 1 commit into
linera-io:testnet_conwayfrom
ndr-ds:ndr-ds/backport-sync-repeat-test-conway

Conversation

@ndr-ds

@ndr-ds ndr-ds commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

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:

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

🤖 Generated with Claude Code

…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)
@ndr-ds
ndr-ds marked this pull request as ready for review September 18, 2026 03:02
@ndr-ds
ndr-ds merged commit 2e51130 into linera-io:testnet_conway Sep 18, 2026
38 checks passed
@ndr-ds
ndr-ds deleted the ndr-ds/backport-sync-repeat-test-conway branch September 18, 2026 03:02
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