test(CPL-322): add Forge tests for AccountConfig diamond contracts#349
Open
GTC6244 wants to merge 1 commit into
Open
test(CPL-322): add Forge tests for AccountConfig diamond contracts#349GTC6244 wants to merge 1 commit into
GTC6244 wants to merge 1 commit into
Conversation
Sets up Foundry side-by-side with the existing Hardhat tooling and adds 39 tests across three suites covering the AccountConfig diamond: - Diamond plumbing: loupe routing, supportsInterface, ownership transfer, diamondCut gating, fallback + direct-ETH reverts, constructor defaults. - Writes/Views round-trips: account creation (ChainSecured + managed), group/usage-key/action/PKP CRUD, ChainSecured conversion flow. - Access control: APIConfig and Billing gating (owner / api payer / admin api payer / config operator / pricing operator) and rejection paths. A new contract-tests.yml workflow runs forge build + forge test on push and PR. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Comment on lines
+16
to
+17
| /// @notice Test-only helper that deploys an `AccountConfig` diamond with all | ||
| /// production facets cut in. Mirrors the production Rust `contract_deployer`. |
Comment on lines
+163
to
+167
| function test_listGroupContents_unknownAccountReverts() public { | ||
| uint256 hash = apiKeyHashOf(user); | ||
| vm.expectRevert(abi.encodeWithSelector(AppStorage.AccountDoesNotExist.selector, hash)); | ||
| views_.getAccountWalletAddress(hash); | ||
| } |
| - name: Install Foundry | ||
| uses: foundry-rs/foundry-toolchain@v1 | ||
| with: | ||
| version: stable |
Comment on lines
+52
to
+54
| // FunctionNotFound(bytes4) selector + arbitrary bytes4 | ||
| bytes4 unknown = bytes4(0xdeadbeef); | ||
| (bool ok,) = d.diamond.call(abi.encodePacked(unknown)); |
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.
Summary
AccountConfigdiamond and its 7 facets, plus aDiamondDeployhelper that mirrors the production Rust deployer.contract-tests.ymlCI workflow that runsforge build+forge teston push and PR.Test coverage
supportsInterfacefor IERC165 / IDiamondCut / IDiamondLoupe / IERC173, ownership transfer gating,diamondCutowner-only, fallback on unknown selector, direct-ETH revert, constructor-set defaults (pricing, operators, requestedApiPayerCount).setApiPayersrejects a regular api payer (only owner / admin api payer permitted, preventing hostile takeover).Out of scope here (good follow-ups): per-usage-key permission flows (
canCreateGroup,canAddPkpToGroup, …), Stripe-adjacent billing surface beyond credit/debit, and fuzz/invariant tests.Test plan
forge buildcleanforge test— 39 / 39 passing locallycontract-testsgreen on this PR🤖 Generated with Claude Code