testing

Write Foundry tests for Solidity smart contracts using fuzz and invariant testing.

1|Updated Apr 25, 2026
One-click install
npx skills add https://github.com/collat-labs/collat --skill testing-collat-labs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing
Source: https://github.com/collat-labs/collat/tree/main/.agents/skills/ethskills/testing
Command: npx skills add https://github.com/collat-labs/collat --skill testing-collat-labs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you prevent financial and integration failures in Ethereum-style smart contracts by guiding you toward testing strategies that uncover edge cases, economic invariant breaks, and real-world protocol interactions.

Core Features & Use Cases

  • Unit testing with meaningful assertions: Focus tests on custom business logic, failure modes, access control boundaries, and economic behavior rather than trivial getters.
  • Fuzz testing for math and user input: Use property-based randomized inputs (with proper bounding) to find bugs you didn’t think of.
  • Fork testing for external integrations: Run tests against real deployed protocol state on a fork to detect integration issues that mocks can hide.
  • Invariant testing for stateful systems: Validate properties that must hold across long, random sequences of actions (crucial for vaults, AMMs, lending).

Quick Start

Use the testing Skill to write Foundry tests that target edge-case reverts, fuzz important functions, and add invariant checks for your vault-style stateful contract.

Frequently Asked Questions about testing

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

FAQPage Schema
What is invariant testing for smart contracts and when do I need it?

Invariant testing validates properties that must hold across long, random sequences of actions, making it essential for stateful systems like vaults, AMMs, and lending protocols. It uncovers economic invariant breaks that standard unit tests miss.

How do I write fuzz tests in Foundry that find edge cases in Solidity math?

Fuzz testing in Foundry uses property-based randomized inputs with proper bounding to find unexpected bugs. You define assertions and input bounds, then the fuzzer generates adversarial inputs to validate custom business logic and failure modes.

Can I fork mainnet state for testing external protocol integrations instead of mocking?

Yes, fork testing runs tests against real deployed protocol state on a fork. It detects integration issues that mocks can hide, ensuring your contract handles real economic conditions and external protocol calls correctly.

What's the best way to test access control and economic behavior in Solidity contracts?

Focus unit tests on custom business logic, access control boundaries, and economic behavior rather than trivial getters. Meaningful assertions target failure modes and revert conditions specific to your contract's logic.

Why do mock-only tests fail to catch smart contract integration bugs?

Mock-only tests hide integration issues because they simulate external protocol behavior artificially. Fork testing against real deployed state reveals actual protocol interactions and integration failures that mocks cannot replicate.

How do I bound inputs for fuzz tests to avoid false positives in Solidity contracts?

Input bounding restricts fuzz test parameters to realistic ranges, preventing false positives from invalid inputs. Proper bounds ensure randomized testing targets meaningful edge cases within your contract's expected operating parameters.