🧪 Testing Guide

The project includes both Solidity contract tests (using Foundry) and frontend tests (using Vitest).

Contract Tests

Foundry tests are written in Solidity and live alongside the contracts in the contracts/test/ directory.

make test-contracts

Test Files

File Tests
MockERC20.t.sol Minting, only-faucet restriction, setFaucet, events, ownership transfer
Faucet.t.sol Claim mETH, claim mBTC, 24h cooldown, time-remaining, lifetime tracking, double-claim revert, onlyOwner setters
MockDEX.t.sol Add liquidity, swap mETH→mUSDC, swap mUSDC→mETH, slippage protection, rate updates, insufficient liquidity, fuzz tests with bound()

Coverage

make coverage

Generates an LCOV coverage report showing line-by-line coverage of all contracts.

Frontend Tests

Frontend tests use Vitest and React Testing Library. Test files live in frontend/tests/.

make test-frontend

Test Areas

Running All Tests

make test

This runs both contract tests and frontend tests sequentially.

Best Practices