What problem does it solve? Smart contract developers often write tests with subtle mistakes — misused cheatcodes, flaky fork tests, ineffective fuzz ranges, or invariant tests that never find bugs — leading to false confidence in contract security. This Skill provides correct, battle-tested testing patterns for Foundry and Hardhat so tests actually catch vulnerabilities. ## Core Features & Use Cases - Foundry Testing Patterns: Unit tests with correct vm.prank/vm.expectRevert/vm.expectEmit usage, custom error assertions, and event ordering checks. - Fuzz & Invariant Testing: Input bounding with bound() vs vm.assume(), handler contracts with ghost variables, and solvency/accounting invariants for DeFi protocols. - Fork Testing: Pinned-block mainnet forks, whale impersonation, multi-fork L1/L2 setups, and tests against deployed Uniswap and Aave contracts. - Hardhat Testing: Mocha/Chai patterns with loadFixture, revert and event matchers, time manipulation, and balance change assertions. - Use Case: When auditing a lending pool, use the invariant handler pattern to fuzz random deposit/borrow/repay sequences and assert that total borrows never exceed total deposits. ## Quick Start Ask the agent to write a Foundry invariant test with a handler contract and ghost variables for your ERC-4626 vault.