fork-testing

Run Foundry tests against pinned live blockchain forks with account impersonation.

120|12|Updated Apr 10, 2026
One-click install
npx skills add https://github.com/ccashwell/evm-cortex --skill fork-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fork-testing
Source: https://github.com/ccashwell/evm-cortex/tree/main/skills/fork-testing
Command: npx skills add https://github.com/ccashwell/evm-cortex --skill fork-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Fork testing lets you run your tests against a snapshot of a live blockchain state, enabling realistic validation of contracts and interactions without deploying mocks.

Core Features & Use Cases

  • Pin forks to a specific mainnet or L2 state using vm.createFork or vm.createSelectFork and reproducible blocks.
  • Impersonate accounts, deal tokens, and simulate DeFi integration flows in a controlled environment.
  • Validate cross-fork scenarios with multi-fork tests and RPC configuration for reliable state replication.

Quick Start

Run Foundry tests in a forked mainnet environment by configuring forge to use an ETH RPC URL and a target block to reproduce live-state conditions.

Frequently Asked Questions about fork-testing

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

FAQPage Schema
What is fork testing in Foundry and when do I need it for smart contracts?

Fork testing runs smart contract tests against a live blockchain snapshot to reproduce real-state conditions. You need it to validate DeFi integration flows and protocol interactions without deploying mocks.

How do I pin a mainnet fork to a specific block using Foundry?

Use vm.createFork or vm.createSelectFork with an ETH RPC URL and target block number to pin the fork. This configuration reproduces live-network states reliably for consistent test execution.

Can I impersonate accounts and deal tokens during mainnet fork testing?

Yes, fork testing supports account impersonation and token dealing within a controlled environment. This allows you to simulate live-network states and validate DeFi patterns against real protocol balances.

Do I need an RPC URL to run forge tests against an L2 fork?

Yes, proper RPC URL handling is required to simulate live-network states for both mainnet and L2 forks. Configuring the RPC URL allows you to pin blocks and access the live blockchain snapshot.

How does fork testing compare to using mocks for DeFi testing?

Fork testing validates contracts against actual live protocol state instead of deploying mocks. This approach exposes real DeFi integration behaviors and cross-fork scenarios that simulated mock environments miss.

Can I test cross-fork scenarios across multiple live blockchain snapshots?

Yes, multi-fork tests allow you to validate cross-fork scenarios using vm.createFork and vm.createSelectFork. Proper RPC configuration ensures reliable state replication across different mainnet or L2 snapshots.