fork-test

Generate Foundry fork tests for smart contracts requiring real on-chain integration coverage.

152|115|Updated Aug 3, 2020
One-click install
npx skills add https://github.com/OriginProtocol/origin-dollar --skill fork-test-originprotocol
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fork-test
Source: https://github.com/OriginProtocol/origin-dollar/tree/main/.codex/skills/fork-test
Command: npx skills add https://github.com/OriginProtocol/origin-dollar --skill fork-test-originprotocol

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing integration tests for DeFi contracts that depend on live liquidity, routers, oracles, and gauges is error-prone without a consistent structure. This Skill enforces the repository's fork test conventions so generated tests match existing patterns for directory layout, inheritance, naming, and chain setup. ## Core Features & Use Cases - Standardized Test Structure: Generates fork tests following the shared/concrete directory layout with the correct inheritance chain from Base through BaseFork to concrete test contracts. - Interface-Only Testing: Enforces interface imports, vm.deployCode deployment via tests/utils/Artifacts.sol, and canonical addresses from tests/utils/Addresses.sol. - Scope Filtering: Applies a litmus test to decide which behaviors belong in fork tests (AMO pools, router swaps, oracle reads, rebases) versus unit tests (setters, access control, pure math). - Use Case: When adding a new OETH strategy that interacts with a Curve pool, use this Skill to generate fork tests covering deposits, withdrawals, and reward flows against a Mainnet fork. ## Quick Start Generate Foundry fork tests for the OETHVault deposit and withdraw flows against a Mainnet fork.

Frequently Asked Questions about fork-test

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

FAQPage Schema
How do I write Foundry fork tests for DeFi smart contracts?

Create a shared setup contract that selects a chain fork, deploys fresh contracts with vm.deployCode, and configures them, then write concrete test files per feature. Use interface types and canonical addresses from the repository's Addresses.sol library.

What belongs in fork tests versus unit tests in Foundry?

Fork tests cover behaviors needing real on-chain state: AMO pool interactions, router swaps, oracle reads, gauge rewards, and vault rebases. Keep setters, access control, constructor validation, and pure math in unit tests where mocks suffice.

How do I deploy contracts in Foundry fork tests without new?

Use vm.deployCode with artifact paths referenced through tests/utils/Artifacts.sol, such as vm.deployCode(Vaults.OETH, abi.encode(address(weth))). Mocks may still use new, and missing entries should be added to the relevant Artifacts sub-library.

Which chains does Foundry fork testing support in this repository?

The repository provides fork helpers for Mainnet, Base, Sonic, and Arbitrum via functions like _createAndSelectForkMainnet() and _createAndSelectForkBase(). Each product maps to a specific chain, such as OUSD and OETH on Mainnet and OSonic on Sonic.

When should I not write a fork test for a contract function?

Skip fork tests when a mock can faithfully reproduce the behavior, such as simple setters, view functions, access control checks, and input-validation reverts. Fork tests should stay narrowly focused on genuine integration value.