testing

Writes Foundry unit, fuzz, fork, and invariant tests for Solidity smart contracts.

Updated Sep 9, 2026
One-click install
npx skills add https://github.com/m-faran/genie-markets --skill testing-m-faran
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: testing
Source: https://github.com/m-faran/genie-markets/tree/main/.agent/skills/ethskills/testing
Command: npx skills add https://github.com/m-faran/genie-markets --skill testing-m-faran

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Smart contract bugs lose real money, yet most test suites only cover happy paths and trivial getters. This Skill guides you to write meaningful Foundry tests that target edge cases, failure modes, economic invariants, and real protocol integrations before deployment. ## Core Features & Use Cases - Unit Testing Patterns: Structured test files with assertion patterns for equality, reverts, events, and access control, focused on logic that can lose funds rather than tautological checks. - Fuzz Testing: Property-based tests using bound() and vm.assume() to exercise thousands of random inputs against mathematical operations and value transfers. - Fork Testing: Tests against real deployed protocols like Uniswap on a mainnet fork to catch integration bugs that mocks hide. - Invariant Testing: Handler-based invariant suites that verify properties like solvency and share pricing hold across thousands of random call sequences. - Use Case: Before deploying a vault contract, use this Skill to generate fuzz tests for deposit/withdraw roundtrips, fork tests against the real USDC contract, and an invariant proving total assets always equals the contract balance. ## Quick Start Write Foundry tests for my smart contract including fuzz tests for the math functions and an invariant test for the deposit and withdraw flow.

Frequently Asked Questions about testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write fuzz tests in Foundry?▼

Add parameters to any test function and Foundry automatically fuzzes it with random values. Use bound() to reshape inputs into valid ranges rather than vm.assume(), which discards inputs, and increase coverage with forge test --fuzz-runs 10000.

How to test smart contracts against mainnet protocols with Foundry?▼

Use vm.createSelectFork with an RPC endpoint and a pinned block number to fork mainnet state, then call real deployed contracts like the Uniswap router directly. This catches integration bugs that mocks cannot reproduce.

What is invariant testing in Foundry and when should I use it?▼

Invariant testing runs random sequences of handler function calls and checks that defined properties hold after every sequence. Use it for stateful protocols like vaults, AMMs, and lending contracts where unit tests only cover single paths.

Should I use bound() or vm.assume() for fuzz test inputs?▼

Prefer bound() because it reshapes random inputs into your target range, keeping every fuzz run productive. vm.assume() discards non-conforming inputs, which wastes runs and can cause tests to fail from too many rejections.

What should I not test in a Solidity contract?▼

Skip testing OpenZeppelin internals, Solidity language features, and trivial getters like name() or decimals(). Focus testing effort on custom business logic, math operations, access control boundaries, and economic edge cases.