Skip to content

test(audit): audit tests wait their turn for the chain's lock and move the sealer's clock instead of sleeping - #693

Open
PiquelChips wants to merge 2 commits into
test/database-waitsfrom
test/audit-waits
Open

PiquelChips wants to merge 2 commits into
test/database-waitsfrom
test/audit-waits

Conversation

@PiquelChips

@PiquelChips PiquelChips commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Audit tests polled every 20ms for the sealer's advisory lock, and one of them slept 4.5s of wall time waiting for checkpoint intervals to pass. They now wait their turn for the lock, and move a clock instead of sleeping through it.

Stacked on #692, whose Database::exclusive they use.

Changes

  • Production (to expose a clock to tests): Sealer::failed_at is a tokio::time::Instant. It behaves like the std one in production, and paused tokio time can move it. auth-service's dev-dependencies enable tokio's test-util for this.
  • Fixture::lock waits for AuditChain with Database::exclusive instead of polling try_exclusive.
  • Fixture::drain(lock, pass) replaces three copies of the same loop: run a pass until no event is left unsealed, and count the passes that sealed something. It keeps one // wall-clock: wait. Sealing waits for older transactions anywhere on the shared cluster to end, and PostgreSQL signals nothing when they do.

Tests

  • Every audit test goes through lock and seal_with, and they assert what they did before.

  • sealing_goes_on_when_a_checkpoint_fails and checkpoints_keep_their_interval_while_batches_stay_full run their passes through drain. The second now sleeps only after a pass that sealed nothing, which changes none of its assertions on checkpoint positions.

  • a_failed_checkpoint_is_retried_after_the_interval has two changes:

    • The sealer's own key signs a checkpoint at 6, dated an interval ago. That replaces signing it and then sleeping twice the interval.
    • The wait after the failure is tokio::time::advance(interval) between pause() and resume(). That replaces sleeping one interval. Time is paused only for the jump, so the database queries keep their real timeouts.

    Checked: with the sealer never waiting after a failure, the test fails at "waits". With the sealer never trying again, it fails at "tries again".

I ran all 23 audit tests five times against a scratch cluster, and they passed every time.

Council review

Rounds: 3

Delegate Round 1 Round 2 Round 3
GPT 6.1 Sol no score no score no score
Claude Opus 5.5 8/10 9/10 9/10
Claude Fable 5.2 8/10 8/10 9/10

GPT 6.1 Sol could not take part: its account hit its usage limit.

Note

Written by Claude Opus 5.5 in Claude Code and reviewed by Claude Opus 5.5 and Claude Fable 5.2 (via T3 Code)

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 85ae6d7a-8e6b-4404-83b9-d1622fe0bc34

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@PiquelChips
PiquelChips marked this pull request as ready for review November 22, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

1 participant