Skills / Community / Web3 Contract Testing

Web3 Contract Testing

Test smart contracts thoroughly with Hardhat and Foundry. Covers unit and integration tests, mainnet forking, fixtures, and coverage — so you catch reentrancy, accounting, and access-control bugs before deploying to mainnet.

This skill builds comprehensive test suites for Solidity contracts across both Hardhat and Foundry. It writes unit and integration tests, sets up mainnet forking to test against real protocol state, uses fixtures for fast repeatable runs, and measures coverage — targeting the failure modes that drain funds: reentrancy, rounding and accounting errors, and broken access control.

web3 hardhat foundry solidity testing

When to use

Use when testing Solidity smart contracts, setting up Hardhat or Foundry test suites, writing unit and integration tests, forking mainnet for tests, or hardening contracts against reentrancy and access-control bugs before deployment.

Examples

Fork mainnet in tests

Test against real protocol state

Set up a Hardhat mainnet-fork test that impersonates a whale account and verifies my contract interacts correctly with the live Aave pool

Foundry reentrancy test

Prove a contract resists reentrancy

Write a Foundry test with a malicious reentrant caller to prove my withdraw function follows checks-effects-interactions and can't be drained

Coverage gaps

Find untested branches

Run coverage on my contract test suite and write tests for the uncovered branches, especially the access-control revert paths
Added to wishlist