test(contracts): expand test suite to ~95% scenario coverage 🧪#32
test(contracts): expand test suite to ~95% scenario coverage 🧪#32Klazomenai merged 3 commits intomainfrom
Conversation
Add 22 new tests covering: - Self-referential operations (admin grants/revokes self) - State transition cycles (grant/revoke/re-grant, add/remove/re-add) - Admin/access independence (removeAdmin does not revoke access) - Removed admin cannot act (grantAccess, addAdmin revert) - Multi-admin complex scenarios (3 admins, cross-admin ops) - Full lifecycle integration test - 6 fuzz tests (1000 runs each) for access control enforcement - 3 invariant tests (256 runs, depth 64) with handler contract Configure foundry.toml with fuzz/invariant settings and gas reports. Refs #25
There was a problem hiding this comment.
Pull request overview
Expands the Foundry test suite for KeyRAAccessControl to increase scenario coverage by adding additional unit tests plus new fuzz and invariant-based tests, and configures Foundry to run them at higher intensity.
Changes:
- Add multiple scenario/unit tests covering self-ops, state transition cycles, removed-admin behavior, multi-admin scenarios, and a full lifecycle flow.
- Introduce a new invariant test suite with a handler contract to drive random sequences of admin/access operations.
- Update
foundry.tomlto enable gas reports and set fuzz/invariant run parameters.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
contracts/test/AccessList.t.sol |
Adds ~22 new scenario + fuzz tests for admin/access behavior and lifecycle flows. |
contracts/test/AccessList.invariant.t.sol |
Adds invariant harness + invariants for KeyRAAccessControl. |
contracts/foundry.toml |
Configures fuzz/invariant run counts and gas reporting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Remove redundant invariant_adminCountMatchesMinimum (same as NeverZero)
- Remove incorrect invariant_atLeastOneKnownAdminExists (third admin
can replace both known admins)
- Replace blanket catch {} with _expectKnownError that only swallows
expected revert selectors and propagates unexpected ones
- Remove dead address(0) guards (already excluded by _boundAddr)
- Add invariant_operationsExercised to detect misconfigured handler
- Track successful operation counts for observability
Refs #25
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Use assembly to revert with original ABI-encoded data instead of casting to string, so Foundry can decode the actual error selector. Refs #25
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
foundry.tomlconfigured with fuzz/invariant settings and gas reportsNew Test Categories
Coverage
Refs #25
Test plan
forge test -vv— 48 tests pass (2 test suites)