
assertion-troubleshooting
Diagnoses common assertion failures and non-triggering issues. Use when assertions fail unexpectedly
提供方 phylaxsystems|开源
Assertion Troubleshooting
Use this when assertions fail unexpectedly, revert with OutOfGas, or never execute.
When to Use
- Tests show "Expected 1 assertion to be executed, but 0 were executed".
- Assertions revert with
OutOfGasor unknown reasons. - Call inputs appear empty or duplicate.
When NOT to Use
- You need invariant design. Use
designing-assertions. - You need implementation details. Use
implementing-assertions. - You need test strategy or fuzzing. Use
testing-assertions.
Quick Start
- Confirm the registered V2 trigger matches the intended target path:
registerFnCallTrigger,registerTxEndTrigger,registerErc20ChangeTrigger, cumulative flow trigger, or storage trigger. - Ensure
cl.assertion()is immediately before the monitored external call; the next monitored call consumes it. - Check if the target call reverted before assertions ran.
- Verify
ph.*calls are used in assertion functions, not constructors. - Remember internal Solidity calls are not traced; triggers only fire on external entrypoints.
- Use
pcl test -vvvvfor full traces and gas diagnostics. - Confirm
FOUNDRY_PROFILE=assertionswhen runningpcl test. - Use
pcl testfor assertion behavior; useforge testonly for regular protocol tests or compile-only checks. - If the failure is
CreateContractSizeLimit, split assertions into smaller contracts. - If the failure is an empty revert or ABI decode panic, re-check whether the API returns raw calldata with selector (
ph.callinputAt) or args-only data. - If
ph.context()reverts, the assertion was not triggered byregisterFnCallTrigger. - If a rolling-window breaker does not fire, confirm the watched token, threshold bps, window duration, and adopter balance source.
Rationalizations to Reject
- "The assertion should have run." Verify triggers and call order first.
- "It is probably a test issue." Validate the target call succeeds without assertions.
- "Gas is fine." Happy path often consumes the most gas.
- "The old fork-switching example should be enough." Prefer current V2 fork-aware reads for new assertions.