Skip to content

test: SnapchainConfigRegistry suite with golden validators.toml parity - #492

Merged
topocount merged 1 commit into
kjs/neyn-13020-c3-config-toml-rendererfrom
kjs/neyn-13021-c4-snapchain-config-registry-tests
Aug 5, 2026
Merged

test: SnapchainConfigRegistry suite with golden validators.toml parity#492
topocount merged 1 commit into
kjs/neyn-13020-c3-config-toml-rendererfrom
kjs/neyn-13021-c4-snapchain-config-registry-tests

Conversation

@topocount

@topocount topocount commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Motivation

Describe why this issue should be fixed and link to any relevant design docs, issues or other relevant items.

Change Summary

Describe the changes being made in 1-2 concise sentences.

Merge Checklist

Choose all relevant options below by adding an x now or at any time before submitting for review

Additional Context

If this is a relatively large or complex change, provide more details here that will help reviewers.


Stack created with GitHub Stacks CLIGive Feedback 💬


PR-Codex overview

This PR introduces a test suite for the SnapchainConfigRegistry contract, focusing on validator set management and peer configuration for the Snapchain mainnet. It includes various helper functions and tests for appending, amending, and validating the registry's state.

Detailed summary

  • Created SnapchainConfigRegistryTestSuite with setup for testing.
  • Added constants for validator keys and bootstrap peers.
  • Implemented helper functions for appending and amending validator sets.
  • Developed multiple test cases for validator set management, including fuzz tests.
  • Ensured proper validation of shard IDs and public keys.
  • Added events for appending, amending, and removing validator sets.
  • Created tests for effective height management and permissions.
  • Implemented tests for TOML injection and rendering correctness.
  • Added gas usage tests to ensure efficiency at scale.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copilot AI lite review requested due to automatic review settings August 4, 2026 21:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a comprehensive Foundry test suite around SnapchainConfigRegistry, including mainnet-seeded “golden” TOML output checks and extensive fuzz/regression coverage to validate storage correctness, rendering invariants, input validation, and gas bounds.

Changes:

  • Introduces a shared SnapchainConfigRegistryTestSuite with mainnet seed data and helper utilities.
  • Adds a full SnapchainConfigRegistry test file covering append/amend/remove semantics, peer-string allowlisting (TOML injection resistance), pagination composition, event emission, and configVersion monotonicity.
  • Adds a golden mainnet configToml() snapshot test plus a scale/gas regression guard.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
test/SnapchainConfigRegistry/SnapchainConfigRegistryTestSuite.sol New base test suite: deploy/setup, mainnet seed fixtures, and helper utilities (_append, _amend, _count, etc.).
test/SnapchainConfigRegistry/SnapchainConfigRegistry.t.sol New tests for correctness, validation, rendering invariants, golden config output, events, pagination, versioning, and gas guardrails.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/SnapchainConfigRegistry/SnapchainConfigRegistryTestSuite.sol Outdated
@topocount
topocount force-pushed the kjs/neyn-13021-c4-snapchain-config-registry-tests branch from 2bde2c5 to c50e692 Compare August 4, 2026 21:50
@topocount
topocount force-pushed the kjs/neyn-13021-c4-snapchain-config-registry-tests branch 2 times, most recently from a8fef14 to dd4464b Compare August 4, 2026 21:58
@topocount
topocount force-pushed the kjs/neyn-13021-c4-snapchain-config-registry-tests branch 2 times, most recently from 37d5779 to 85a58e1 Compare August 4, 2026 22:13
@topocount
topocount force-pushed the kjs/neyn-13021-c4-snapchain-config-registry-tests branch from 85a58e1 to 7d02804 Compare August 5, 2026 20:55
46 tests. The ones that earn their keep:

Storage correctness. testFuzzAmendShrinksArrays is the test that catches
a botched nested-array copy -- it amends from n keys down to m and
asserts both the stored length and the rendered line count, so a copy
that leaves the tail of the previous value behind fails loudly.
testRemoveThenAppendDoesNotLeakStaleKeys covers the explicit clear
before pop(): without it a later push inherits the removed entry's
contents, which is a removed validator silently coming back.

Injection. testPeerCharAllowlist walks all 256 byte values and
cross-checks each against a predicate written from the spec rather than
from the contract's bitmap, which is what makes two opaque hex constants
safe to merge. The enumerated payload tests read as documentation of the
threat; testFuzzConfigTomlHasBalancedQuotes is the property behind them,
asserting the quote count is exactly two per key plus four regardless of
input.

testFuzzAppendEqualEffectiveAt must pass, not fail -- it documents that
the bound is >= and that same-height per-shard entries are legal.

Golden output. Seeds mainnet's ten validator sets and asserts the
rendered document byte for byte. It is deliberately not identical to
validators.toml, which carries comments, underscore-separated integers
and inner-spaced arrays; a TOML parser cannot tell the forms apart, and
the constant is the normalized one.

The gas guard found a real defect rather than just standing watch: at 32
entries by 16 keys the getter cost 11.2M gas, over the strictest public
eth_call cap. The renderer fix is in the preceding commit; this now
passes at 3.2M for the same 41KB of output.
@topocount
topocount force-pushed the kjs/neyn-13021-c4-snapchain-config-registry-tests branch from 7d02804 to 2db7b6c Compare August 5, 2026 21:08
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Coverage after merging kjs/neyn-13021-c4-snapchain-config-registry-tests into kjs/neyn-13020-c3-config-toml-renderer will be

100.00%

Coverage Report
FileStmtsBranchesFuncsLinesUncovered Lines
src
   Bundler.sol100%100%100%100%
   BundlerV1.sol100%100%100%100%
   FnameResolver.sol100%100%100%100%
   IdGateway.sol100%100%100%100%
   IdRegistry.sol100%100%100%100%
   KeyGateway.sol100%100%100%100%
   KeyRegistry.sol100%100%100%100%
   RecoveryProxy.sol100%100%100%100%
   SnapchainConfigRegistry.sol100%100%100%100%
   StorageRegistry.sol100%100%100%100%
   TierRegistry.sol100%100%100%100%
src/abstract
   EIP712.sol100%100%100%100%
   Guardians.sol100%100%100%100%
   Migration.sol100%100%100%100%
   Nonces.sol100%100%100%100%
   Signatures.sol100%100%100%100%
src/validators
   SignedKeyRequestValidator.sol100%100%100%100%

@topocount
topocount merged commit 1b6e140 into main Aug 5, 2026
8 checks passed
@topocount
topocount deleted the kjs/neyn-13021-c4-snapchain-config-registry-tests branch August 5, 2026 21:47
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.

2 participants