test(contracts): add bridge adapter invariant fuzz tests#47
Conversation
Three invariants covering MARKBridgeAdapter rate limiting logic: - dailyCapNeverExceeded: bridgedInDailyCapEpoch <= dailyCap within epoch - accumulatorConsistentWithCap: accumulator never exceeds cap regardless of limit resets or epoch changes - operatorRoleNeverZeroAddress: zero address never holds OPERATOR_ROLE Handler exercises bridge calls, time advancement, and limit updates across 64 fuzz runs. Fuzzer identified and confirmed epoch-0 edge case (bridge call at timestamp < 1 day sets epoch=0 with non-zero accumulator) is handled correctly by the contract.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR introduces a Foundry invariant test suite for ChangesBridge Invariant Test Suite
Estimated Code Review Effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly Related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
Adds invariant fuzz tests for
MARKBridgeAdapterrate limiting logic. The settlement module already has a full invariant suite; this closes the gap for the bridge.Tests added
contracts/test/invariant/bridge/MARKBridgeInvariants.t.solinvariant_dailyCapNeverExceeded: accumulator never exceedsdailyCapwithin the current epochinvariant_accumulatorConsistentWithCap: accumulator never exceeds cap regardless of limit resets or epoch changesinvariant_operatorRoleNeverZeroAddress: zero address never holdsOPERATOR_ROLEHandler fuzzes: bridge calls, time advancement (up to 3 days), and limit updates.
Verification
forge test: 74 tests passed, 0 failed (up from 71)Scope
contractsRisk
None — test-only addition.
Summary by CodeRabbit