test: SnapchainConfigRegistry suite with golden validators.toml parity - #492
Merged
topocount merged 1 commit intoAug 5, 2026
Conversation
There was a problem hiding this comment.
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
SnapchainConfigRegistryTestSuitewith mainnet seed data and helper utilities. - Adds a full
SnapchainConfigRegistrytest 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.
topocount
force-pushed
the
kjs/neyn-13021-c4-snapchain-config-registry-tests
branch
from
August 4, 2026 21:50
2bde2c5 to
c50e692
Compare
topocount
force-pushed
the
kjs/neyn-13021-c4-snapchain-config-registry-tests
branch
2 times, most recently
from
August 4, 2026 21:58
a8fef14 to
dd4464b
Compare
topocount
force-pushed
the
kjs/neyn-13021-c4-snapchain-config-registry-tests
branch
2 times, most recently
from
August 4, 2026 22:13
37d5779 to
85a58e1
Compare
topocount
force-pushed
the
kjs/neyn-13021-c4-snapchain-config-registry-tests
branch
from
August 5, 2026 20:55
85a58e1 to
7d02804
Compare
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
force-pushed
the
kjs/neyn-13021-c4-snapchain-config-registry-tests
branch
from
August 5, 2026 21:08
7d02804 to
2db7b6c
Compare
|
Coverage after merging kjs/neyn-13021-c4-snapchain-config-registry-tests into kjs/neyn-13020-c3-config-toml-renderer will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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
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
xnow or at any time before submitting for reviewAdditional Context
If this is a relatively large or complex change, provide more details here that will help reviewers.
Stack created with GitHub Stacks CLI • Give Feedback 💬
PR-Codex overview
This PR introduces a test suite for the
SnapchainConfigRegistrycontract, 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
SnapchainConfigRegistryTestSuitewith setup for testing.