Check logical state properties across every modifying path.
LET’S PICTURE IT
A cabinet can have valid drawer positions while its records still contradict each other.
SEE IT FOR YOURSELF
Pack small values into Solidity storage slotsStep 1 / 4
In this simple default-layout example, two uint128 values come before one uint256. Each slot holds thirty-two bytes.
In this simple default-layout example, two uint128 values come before one uint256. Each slot holds thirty-two bytes.The first sixteen-byte value occupies the low-order half of slot zero. Low-order bytes are shown on the right.The second uint128 fits in the remaining sixteen bytes. Both values now share slot zero.C needs a complete thirty-two-byte slot, so it begins at slot one. Two packed small values plus C use two slots.
Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.
Separate layout from accounting
Compiler output identifies positions and types. An invariant concerns meaning, such as total recorded credits remaining bounded by accounted assets.
Exercise all relevant transitions
Deposits, withdrawals, fees and emergency actions can change the property. A fixture should include the paths that the stated invariant covers.
Check after failures too
Rejected actions should leave the relevant state consistent. Catching a child failure can require explicit parent-side handling rather than a blanket rollback assumption.
Keep assumptions visible
Supported token behavior, direct donations and rounding can change the correct property. A test oracle must match those assumptions.
Define the test
before action: assert invariant
perform allowed or rejected action
after action: assert invariant
repeat across multiple actors and sequences
Test plans are framework-neutral unless labeled as complete Solidity or JavaScript. Use a local test environment and no real funds.
QUICK CHECK · NO PRESSURE
Does correct field packing prove a financial accounting invariant?
Storage positions and logical conservation are different properties.