blockchain-smart-contract-testing
Installation
SKILL.md
Blockchain & Smart Contract Testing
Deployed contracts are immutable, public and hold value: bugs are exploited within minutes. Test far beyond happy paths.
Layered approach
- Unit (Foundry
forge test, Hardhat + Chai): each function, revert reasons, events, access control. - Fuzz:
forge testproperty fuzzing (function testFuzz_Deposit(uint96 amt)). - Invariant / stateful fuzz: system-wide rules that must always hold — e.g.
sum(balances) == totalSupply,solvency: assets >= liabilities,share price never decreases except by loss event. (Foundry invariant tests, Echidna, Medusa.) - Fork tests: run against mainnet state (
forge test --fork-url $RPC --fork-block-number N) for integrations (Uniswap, Chainlink, Aave). - Static analysis:
slither ., Mythril, Aderyn; formal verification for critical logic (Certora, Halmos, SMTChecker). - Gas & size:
forge snapshot,forge test --gas-report, contract size ≤ 24 KB. - dApp/E2E: Playwright + wallet stubs (Synpress) / local Anvil/Hardhat node.
- Audit & bounty before mainnet; testnet soak; timelock + pause switch.