Skip to content

test(contracts): cover the registry double-init guard - #285

Merged
lolaaimar merged 1 commit into
fix/zk-tls-witness-pinfrom
fix/240-registry-double-init-test
Nov 25, 2026
Merged

lolaaimar merged 1 commit into
fix/zk-tls-witness-pinfrom
fix/240-registry-double-init-test

Conversation

@nicolasLuduena

@nicolasLuduena nicolasLuduena commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #240. Stacked on #294 (stack: #291 → #292 → #293 → #294 → #285); it shares no files with them.

No test reached the Registry already initialized assert in attestor_registry.compact, so a change that dropped it would pass CI. initRegistry writes the sealed keys ledger, so only a constructor can call it. A new mock calls it twice there:

// packages/contracts/test/mocks/MockRegistryDoubleInit.compact
import "../../attestor_registry"<3, 20> prefix R_;

constructor() {
  R_initRegistry();
  R_initRegistry();
}

registry.test.ts deploys that mock with three distinct keys and expects the deploy to fail with Registry already initialized.

 package.json, packages/contracts/package.json
   compact, compact:no-zk
     MockAttestation        → artifacts/mock_attestation
     MockAttestationBytes   → artifacts/mock_attestation_bytes
     MockAddressHash        → artifacts/mock_address_hash
+    MockRegistryDoubleInit → artifacts/mock_registry_double_init

The registry.test.ts header used to point at sealed-init.test.ts, which doesn't exist; it now lists the double-init guard among its own tests. AGENTS.md's Testing section names the new mock. The compiler stays at +0.36.1 and compact-runtime at 0.21.0.

The header's other guard, the compile error you get if you export initRegistry, still has no test. That needs a test that runs the compiler, and #240 doesn't ask for one.

Evidence

  • Before: with the assert commented out in attestor_registry.compact, every registry test passes, so nothing guarded it.
    After: the same mutation fails the new test, and restoring the assert makes all 10 registry tests pass:

    × registry init > rejects a second initRegistry call
      → promise resolved "{ …(3) }" instead of rejecting
    
    ✓ registry init > rejects a second initRegistry call
    Tests  10 passed (10)
    

With the full stack below it, all four mocks compile with npm run compact:no-zk. Build, npm run types and npm run check (Biome and compact format -c) pass. The full suite passes: 775 passed, 4 skipped (the opt-in live checks).

No verification skill in this repo.

Merge Danger

Door: two-way

Blast Radius: none

A test, a test-only mock and the scripts that compile it. Nothing published changes, so there is no changeset. npm test compiles one more mock, which adds a few seconds.

@nicolasLuduena nicolasLuduena left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@lolaaimar lolaaimar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@lolaaimar
lolaaimar force-pushed the fix/240-registry-double-init-test branch from e472e40 to 6854a49 Compare November 25, 2026 19:49
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e11aac5e-6fa9-4ec8-a820-a12c71045eba
  • 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

@lolaaimar
lolaaimar force-pushed the fix/240-registry-double-init-test branch from 6854a49 to 53781a0 Compare November 25, 2026 20:47
@lolaaimar
lolaaimar merged commit 84750ee into main Nov 25, 2026
3 checks passed
@lolaaimar
lolaaimar deleted the fix/240-registry-double-init-test branch November 25, 2026 20:50
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.

contracts: registry.test.ts points at a sealed-init test that doesn't exist, and the init guards are untested

2 participants