test: salvage audit triage tests from #2514#2581
Conversation
Brings across commit 91f6e95 from the closed PR #2514 onto post-rename main, with file paths and identifiers updated for the OrderBook -> Raindex rename: New tests covering audit-flagged paths: - spender != pool path in GenericPool _exchange (#2533) - receive() and fallback() payable in RouteProcessor arb (#2534) - onTakeOrders2 fuzz on RouteProcessor arb - LibRaindexArb finalizeArb zero-balance and fuzz (#2537) - LibRaindex doPost edge cases (#2536) - RaindexV6 takeOrder min IO is output, zero amount (#2535) - RaindexV6 multicall, negativePullPush, negativeVaultBalance(Change) Test infrastructure changes: - LibTestArb.setup and LibTestFlashBorrowerArb.setup now take separate spender and pool addresses (with a single-argument convenience overload) so split-spender exchange data can be exercised. - RaindexV6SelfTest deploys the TOFU singleton in its constructor so internal token-decimals lookups work in tests that exercise them. - New SplitSpenderExchange helper exposing a SpenderProxy and SplitSpenderPool pair. LibOrder.t.sol gets a fuzzed hash-mutation test that proves changing a single field always changes the hash. forge build passes on the resulting tree.
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR adds comprehensive test coverage for Raindex V6 core flows and edge cases. New tests validate split-spender approval patterns, ETH receive/fallback acceptance, negative-amount reverts, zero-amount order handling, Float parameter fuzz testing, and arbitrage finalization invariants. Test infrastructure is updated to support TOFU token-decimals initialization and to distinguish spender and pool roles in exchange operations. ChangesTest Coverage Expansion for Raindex V6 Core Flows and Edge Cases
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
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)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/concrete/arb/RouteProcessorRaindexV6ArbOrderTaker.onTakeOrders2Fuzz.t.sol (1)
42-49: ⚡ Quick winAvoid swallowing all revert causes in fuzz path.
The empty
catch {}will also hide unexpected regressions (not just invalid float conversions), so this test can pass while behavior is broken. Please assert/whitelist expected revert classes, or add a dedicated non-catching success-case test alongside this fuzz test.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/concrete/arb/RouteProcessorRaindexV6ArbOrderTaker.onTakeOrders2Fuzz.t.sol` around lines 42 - 49, The fuzz test currently swallows all reverts with an empty catch when calling arb.onTakeOrders2(address(tokenA), address(tokenB), inputAmountSent, totalOutputAmount, route), hiding real regressions; update the test to either catch and assert only the expected revert types/messages (whitelist the known float-conversion or invalid-parameter revert reasons) or remove the blanket catch and add a separate deterministic success-case test that calls onTakeOrders2 without catching so tokenA.balanceOf(address(arb)) and tokenB.balanceOf(address(arb)) are asserted on success; ensure you reference the same call site (arb.onTakeOrders2) and balance assertions when implementing the whitelist or the dedicated success test.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@test/concrete/arb/RouteProcessorRaindexV6ArbOrderTaker.onTakeOrders2Fuzz.t.sol`:
- Around line 42-49: The fuzz test currently swallows all reverts with an empty
catch when calling arb.onTakeOrders2(address(tokenA), address(tokenB),
inputAmountSent, totalOutputAmount, route), hiding real regressions; update the
test to either catch and assert only the expected revert types/messages
(whitelist the known float-conversion or invalid-parameter revert reasons) or
remove the blanket catch and add a separate deterministic success-case test that
calls onTakeOrders2 without catching so tokenA.balanceOf(address(arb)) and
tokenB.balanceOf(address(arb)) are asserted on success; ensure you reference the
same call site (arb.onTakeOrders2) and balance assertions when implementing the
whitelist or the dedicated success test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 17891719-8aa4-4814-8d22-10aafbc640cc
📒 Files selected for processing (19)
test/concrete/arb/GenericPoolRaindexV6ArbOrderTaker.splitSpender.t.soltest/concrete/arb/GenericPoolRaindexV6FlashBorrower.splitSpender.t.soltest/concrete/arb/RouteProcessorRaindexV6ArbOrderTaker.fallback.t.soltest/concrete/arb/RouteProcessorRaindexV6ArbOrderTaker.onTakeOrders2Fuzz.t.soltest/concrete/arb/RouteProcessorRaindexV6ArbOrderTaker.receive.t.soltest/concrete/raindex/RaindexV6.multicall.t.soltest/concrete/raindex/RaindexV6.negativePullPush.t.soltest/concrete/raindex/RaindexV6.negativeVaultBalance.t.soltest/concrete/raindex/RaindexV6.negativeVaultBalanceChange.t.soltest/concrete/raindex/RaindexV6.takeOrder.minimumIOIsOutput.t.soltest/concrete/raindex/RaindexV6.takeOrder.zeroAmount.t.soltest/lib/LibOrder.t.soltest/lib/LibRaindex.doPost.t.soltest/lib/LibRaindexArb.finalizeArbFuzz.t.soltest/lib/LibRaindexArb.finalizeArbZeroBalance.t.soltest/util/abstract/RaindexV6SelfTest.soltest/util/concrete/SplitSpenderExchange.soltest/util/lib/LibTestArb.soltest/util/lib/LibTestFlashBorrowerArb.sol
Salvaged tests almost-perfectly but dropped a 1-line comment from the upstream audit commit. Restoring it so the new PR matches the original intent verbatim.
Salvages commit `91f6e9503` from the now-closed #2514 onto post-rename main, with file paths and identifiers translated for the OrderBook → Raindex rename.
What's in here
New tests covering audit-flagged paths:
_exchangeTest infrastructure changes:
LibTestArb.setupandLibTestFlashBorrowerArb.setupnow take separatespenderandpooladdresses, with a single-argument convenience overload (exchange == spender == pool) so existing callers keep working. Lets split-spender tests exercise the exchange-data unpacking path.RaindexV6SelfTestdeploys the TOFU singleton in its constructor viaLibRainDeployso internal token-decimals lookups work in tests that exercise them.test/util/concrete/SplitSpenderExchange.solexposing aSpenderProxy+SplitSpenderPoolpair for the split-spender tests.Provenance
Original commit on the old
2026-03-13-auditbranch:91f6e9503 Add audit triage tests for OB internals, arb paths, and doPost(21 files, +639/-36). #2514 itself is being closed as superseded — the other two commits there were a now-obsoleteiOrderbook→constantrefactor (rendered moot by the rename's sweeping changes) and a triage-MD update against a file that was deleted in #2526.Path/identifier translation applied:
test/concrete/ob/OrderBookV6.*.t.sol→test/concrete/raindex/RaindexV6.*.t.soltest/concrete/arb/GenericPoolOrderBookV6*/RouteProcessorOrderBookV6*→*RaindexV6*test/lib/LibOrderBook*→test/lib/LibRaindex*src/abstract/OrderBookV6FlashBorrower.sol→src/abstract/RaindexV6FlashBorrower.solOrderBookV6 → RaindexV6,LibOrderBook → LibRaindex,iOrderbook → iRaindex,setup.orderBook → setup.raindex,obPullAmount → raindexPullAmount,obOutputAmount → raindexOutputAmountforge buildpasses on the resulting tree.🤖 Generated with Claude Code
Summary by CodeRabbit
Tests