You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Per the Source of Truth (Section 10, Week 3-4 deliverable), the FishnetWallet needs a comprehensive Foundry test suite covering all permit validation paths, owner functions, and edge cases. The contract is security-critical — it gates real fund execution.
Test File
File:contracts/test/FishnetWallet.t.sol
1. Test Setup
Deploy FishnetWallet with test owner and test signer addresses
Fund wallet with test ETH (e.g., vm.deal)
Deploy a mock target contract (simple receive() + a state-changing function)
[SC-2] Comprehensive Foundry Test Suite for FishnetWallet
Labels:
smart-contract,testing,priority:high,week-3-4Assignee: Yash
Context
Per the Source of Truth (Section 10, Week 3-4 deliverable), the FishnetWallet needs a comprehensive Foundry test suite covering all permit validation paths, owner functions, and edge cases. The contract is security-critical — it gates real fund execution.
Test File
File:
contracts/test/FishnetWallet.t.sol1. Test Setup
FishnetWalletwith test owner and test signer addressesvm.deal)receive()+ a state-changing function)_signPermit(FishnetPermit memory permit, uint256 signerPrivateKey)— generates valid EIP712 signature off-chain usingvm.sign_buildPermit(...)— constructs permit struct with defaults2. Happy Path Tests
test_executeValidPermit— sign valid permit, callexecute(), verify:ActionExecutedevent emitted with correct argstest_executeMultiplePermitsSequentially— execute 3 permits with incrementing nonces, all succeedtest_executeWithZeroValue— permit withvalue = 0(pure function call, no ETH transfer)test_executeComplexCalldata— permit with realistic swap calldata (Uniswap-like selector + params)3. Permit Validation Failure Tests
Each test verifies the specific revert reason:
test_revert_expiredPermit— setpermit.expirytoblock.timestamp - 1, expect revert"permit expired"test_revert_usedNonce— execute once with nonce=1, try again with nonce=1, expect revert"nonce already used"test_revert_targetMismatch—permit.target = addressA, callexecute(addressB, ...), expect revert"target mismatch"test_revert_calldataMismatch—permit.calldataHash = keccak256(dataA), call withdataB, expect revert"calldata mismatch"test_revert_walletMismatch—permit.wallet = otherAddress(not this contract), expect revert"wallet mismatch"test_revert_invalidSignature— sign with a random key (notfishnetSigner), expect revert"invalid signature"test_revert_zeroAddressSigner— signature that recovers toaddress(0), expect revert4. Pause Tests
test_revert_executeWhenPaused— owner pauses wallet, valid permit still reverts with"wallet paused"test_executeAfterUnpause— pause, unpause, then execute succeedstest_revert_pauseByNonOwner— non-owner callspause(), expect revert"not owner"test_pauseEmitsEvent—pause()emitsPausedeventtest_unpauseEmitsEvent—unpause()emitsUnpausedevent5. Owner Function Tests
test_setSigner— owner callssetSigner(newSigner):SignerUpdatedevent emittedtest_revert_setSignerByNonOwner— non-owner callssetSigner, expect reverttest_withdraw— owner withdraws ETH, verify balance transferredtest_revert_withdrawByNonOwner— non-owner callswithdraw, expect reverttest_receiveETH— send ETH directly to wallet, verify balance increases6. Edge Case Tests
test_revert_executionFailure— target contract reverts (e.g.,revert("nope")), outer call reverts with"execution failed"test_executeExactExpiry—permit.expiry == block.timestamp(boundary condition), should succeedtest_nonceOrdering— nonces don't need to be sequential (nonce=5, then nonce=2, then nonce=99 all work if unused)test_reentryProtection— target contract tries to re-enterexecute()during callback, verify behavior (should fail due to nonce already used)test_largeNonce—nonce = type(uint256).max, verify it workstest_chainIdMismatch— permit signed with wrong chainId, signature recovery produces wrong address, expect revert7. Gas Benchmarks
test_gasExecute— measure gas for a standard execute call, log ittest_gasDeniedPermit— measure gas for a denied (expired) permit, log itAcceptance Criteria
forge test -vvvvm.warp,vm.roll)