testing

Write unit, fuzz, fork, and invariant tests for Solidity contracts using Foundry.

Updated Mar 6, 2026
One-click install
npx skills add https://github.com/andginja/ethskills --skill testing-andginja
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing
Source: https://github.com/andginja/ethskills/tree/main/skills/testing
Command: npx skills add https://github.com/andginja/ethskills --skill testing-andginja

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the challenges of writing robust and effective smart contract tests, moving beyond basic checks to cover edge cases, integration points, and invariants.

Core Features & Use Cases

  • Foundry-centric Testing: Learn to write unit, fuzz, fork, and invariant tests using Foundry, the industry-standard Solidity testing framework.
  • Production-Ready Practices: Understand common pitfalls in smart contract testing, including what LLMs often get wrong, and adopt best practices for security and reliability.
  • Use Case: When developing a new DeFi protocol, use this Skill to write comprehensive tests that simulate real-world interactions, catch potential reentrancy bugs, and verify complex mathematical logic under various conditions before deployment.

Quick Start

Use the testing skill to write a unit test for the deposit function of a Vault contract.

Frequently Asked Questions about testing

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

FAQPage Schema
How do I write effective smart contract tests using Foundry?

To write effective smart contract tests using Foundry, you should implement unit, fuzz, fork, and invariant testing methodologies. This approach catches edge cases and verifies complex DeFi mathematical logic before deployment.

What is invariant testing in Solidity and when do I need it?

Invariant testing in Solidity is a methodology that verifies protocol properties hold true under arbitrary interactions. You need it to catch potential reentrancy bugs and simulate real-world conditions in complex DeFi protocols.

What are common pitfalls in LLM-generated smart contract tests?

Common pitfalls in LLM-generated smart contract tests include insufficient coverage of edge cases, missing integration points, and failing to verify invariants. Production-grade testing strategies emphasize moving beyond basic checks to address these deficiencies.

Can I use Foundry fuzz testing to catch edge cases in DeFi protocols?

Yes, you can use Foundry fuzz testing to catch edge cases in DeFi protocols. Fuzzing allows you to simulate various conditions and verify complex mathematical logic, ensuring security and reliability before mainnet deployment.

Do I need to understand Solidity and DeFi patterns to write production-ready tests?

Yes, you need to understand Solidity, Foundry, and common DeFi patterns to write production-ready tests. This prerequisite knowledge is required to effectively implement comprehensive testing strategies for smart contracts.

What is the best way to test smart contracts for reentrancy vulnerabilities?

The best way to test smart contracts for reentrancy vulnerabilities is using Foundry invariant testing. This methodology simulates real-world interactions to catch potential reentrancy bugs and verify complex protocol logic under various conditions.