INVARIANT TESTING

23 articles tagged "invariant testing"

2025-01-15·12 min read

Why Invariant Testing Matters for DeFi Security

Unit tests check what you think of. Invariant tests check what you don't. Here's why every DeFi protocol needs invariant testing and how it has saved millions in real engagements.

By Alex
invariant-testingdefi-securitysmart-contracts
2025-04-14·10 min read

The Anatomy of a Critical DeFi Bug: Insolvency Through Incorrect Accounting

A single rounding error in share accounting can drain an entire vault. Walk through the anatomy of a real critical DeFi bug and learn why invariant testing is the only reliable way to catch it.

By Alex
smart-contract-securityinvariant-testing
2025-05-19·12 min read

Property Design Patterns for DeFi Lending Protocols

A practical catalog of invariant property patterns for lending protocols — from solvency and utilization bounds to liquidation health checks — with Solidity code for each.

By Nican0r
invariant-testingproperty-based-testingfuzzing
2025-07-28·10 min read

5 Smart Contract Vulnerabilities That Unit Tests Will Never Catch

Unit tests check what you expect. But the most dangerous vulnerabilities hide in the unexpected — cross-function reentrancy, rounding accumulation, and more. Here are five categories unit tests will never catch.

By Alex
smart-contract-securityinvariant-testingfuzzing
2025-10-06·10 min read

Understanding Rounding Errors in DeFi: How Small Bugs Lead to Big Exploits

In Solidity, there are no decimals — only integers and the illusion of precision. Learn how 1 wei rounding errors compound into protocol-draining exploits and how to defend against them.

By Nican0r
smart-contract-securityinteger-overflowinvariant-testing
2026-02-09·12 min read

From Zero to Fuzzing: A Beginner's Guide to the Chimera Framework

A hands-on beginner tutorial for the Chimera framework. Go from an empty project to running invariant tests with Foundry, Echidna, and Medusa — no prior fuzzing experience required.

By Kn0t
chimera-frameworkfuzzinginvariant-testing
2026-02-24·15 min read

Towards the Scientific Audit

Audits today are artisanal. Two auditors reviewing the same code follow different paths and produce different results. This inconsistency is the gap attackers exploit. Here is how we make audits scientific.

By Alex
smart-contract-auditsmart-contract-securityinvariant-testing
2026-03-10·12 min read

AI Smart Contract Audits: Beyond the Hype

Everyone claims AI auditing. Most mean they ran an LLM on your code. Here is what AI-powered smart contract auditing actually looks like when built on top of invariant testing and formal methods.

By Alex
smart-contract-auditsmart-contract-securityinvariant-testing
2026-03-21·10 min read

How to write your first invariant test

A hands-on tutorial that walks you through writing three invariant properties for a simple ERC-20 vault, then running them with Foundry and Echidna. Working test suite in 30 minutes.

By Nican0r
invariant-testingproperty-based-testingfuzzing
2026-03-23·10 min read

Smart contract fuzzing tools compared: Echidna, Medusa, Halmos, and Foundry

Four tools dominate smart contract fuzzing. Each approaches the problem differently, and picking the wrong one wastes time. Here's how to match the right fuzzer to your project — or use all four together.

By Antonio
fuzzingechidnamedusa
2026-03-25·10 min read

What is smart contract fuzzing?

Smart contract fuzzing throws millions of random inputs at your contracts to find states that violate your security assumptions. Here's how it works, what it catches, and how to get started.

By Deivitto
fuzzingsmart-contract-securityinvariant-testing
2026-03-26·9 min read

7 common smart contract fuzzing mistakes (and how to fix them)

Your fuzzer ran for 24 hours and found nothing. That doesn't mean your code is safe — it might mean your campaign was broken. Here are the seven mistakes we see most often and how to fix each one.

By Deivitto
fuzzinginvariant-testingsmart-contract-security
2026-03-27·12 min read

How to fuzz ERC-4626 vaults: a step-by-step guide

ERC-4626 defines a clean vault interface and a set of guarantees that are surprisingly easy to break. This guide walks through identifying invariants, writing properties, and running fuzzing campaigns.

By Deivitto
fuzzinginvariant-testingerc-4626
2026-03-28·11 min read

Foundry fuzz testing: from basic fuzzing to invariant tests

Foundry's built-in fuzzer goes well beyond what most developers use. This guide covers the full spectrum from basic input fuzzing to stateful invariant tests to bridging into dedicated fuzzing tools.

By Deivitto
fuzzinginvariant-testingsmart-contract-security
2026-03-29·12 min read

How to fuzz ERC-6909 multi-token contracts

ERC-6909 is the minimal multi-token standard powering Uniswap v4. This guide walks through identifying invariants, writing properties for per-ID accounting and dual approvals, and running fuzzing campaigns.

By Deivitto
fuzzinginvariant-testingerc-6909
2026-03-30·14 min read

How to fuzz ERC-7540 async vaults

ERC-7540 adds async deposit and redemption flows on top of ERC-4626. This guide covers the lifecycle invariants, handler patterns for operator fulfillment, and campaigns that stress the request-claim state machine.

By Deivitto
fuzzinginvariant-testingerc-7540
2026-03-31·13 min read

How to fuzz ERC-4337 account abstraction wallets

ERC-4337 wallets validate their own transactions and manage gas accounting. This guide covers the invariants that matter for account abstraction, from signature validation to paymaster solvency.

By Deivitto
fuzzinginvariant-testingerc-4337
2026-04-01·12 min read

How to fuzz ERC 2535 diamond proxies: storage, selectors, and upgrades

Diamond proxies delegate calls to multiple facets, and the bugs live in upgrade sequences and storage collisions. This guide covers selector, storage, and loupe invariants with full Chimera properties.

By Deivitto
fuzzinginvariant-testingerc-2535
2026-04-02·11 min read

How to fuzz ERC-1155 multi-token contracts

ERC-1155 combines batch operations with mandatory receiver callbacks, creating a reentrancy surface that single-token testing misses. This guide covers the invariants and handler patterns that catch the real bugs.

By Deivitto
fuzzinginvariant-testingerc-1155
2026-01-26·10 min read

Flash loan exploits: how they work and how invariant testing catches them

Flash loans let anyone borrow millions for a single transaction. When combined with reentrancy or oracle manipulation, they drain protocols in one block. Here's how invariant testing catches what unit tests can't.

By Deivitto
flash-loan-attackdefi-securityfuzzing
2026-02-17·9 min read

Access control bugs in Solidity: real hacks and property-based defense

A missing modifier. A delegatecall to an untrusted address. Access control bugs have caused some of the largest losses in DeFi history. Here's how to find them with property-based testing.

By Deivitto
access-controlsmart-contract-securityinvariant-testing
2026-03-03·11 min read

Halmos symbolic execution for smart contracts: setup, limitations, and when it beats fuzzing

Fuzzers sample randomly. Symbolic execution explores every path. Halmos brings symbolic execution to Foundry — but it's not always the right tool. Here's when it wins and when fuzzing is better.

By Deivitto
fuzzinginvariant-testingsmart-contract-security
2026-03-14·12 min read

ZK circuit security: constraint bugs, witness leaks, and audit patterns

ZK circuits aren't programs — they're constraint systems. The bugs look different: under-constrained signals, witness malleability, missing range checks. Here's how to audit them.

By Deivitto
smart-contract-securityfuzzinginvariant-testing

Need help securing your protocol?