Code Invariant Testing
Code invariant testing involves identifying and continuously verifying the core rules that must never be violated during a contract's execution. Examples include ensuring the total supply of a token remains constant or that a user's debt never exceeds their collateral value.
These invariants are embedded into the test suite and checked after every transaction or state change. If an invariant is broken, the test fails, signaling a potential vulnerability.
This approach forces developers to think deeply about the fundamental rules of their protocol. It is a proactive security measure that helps maintain system integrity throughout the lifecycle of the contract.