Conversation
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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 |
Time Submission Status
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
internal/migrations/032-order-book-actions.sql (1)
698-902: Newplace_split_limit_orderaction is coherent with existing trading flowThe split-limit action’s structure (validation → market status → collateral calc → balance check → participant get/create → lock → YES @0 + NO @ 100-true_price →
match_orders) matches the patterns used inplace_buy_order/place_sell_order, and the collateral/price math aligns with the tests (1 TRUF per pair, NO price = 100 − true_price). Error messages also match the test assertions that useContains.As a minor follow-up, you might consider extracting the repeated caller-format validation and participant get-or-create logic into shared helpers or a private action to DRY up
place_buy_order,place_sell_order, andplace_split_limit_order, but that’s optional and can be deferred.tests/streams/order_book/split_limit_order_test.go (1)
72-136: Consider factoring the manual-settlement test shortcut into a shared helperThe manual settlement block here (creating a
TxContextwithOverrideAuthz: trueandUPDATE ob_queries SET settled = true) is very similar in intent to the shortcut used intestSellOrderMarketSettledinsell_order_test.go. Extracting a smallsettleMarketForTesting(ctx, platform, marketID)helper shared across test files would reduce duplication and keep the settlement stub behavior consistent if it ever needs tweaking.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
internal/migrations/032-order-book-actions.sql(1 hunks)tests/streams/order_book/sell_order_test.go(1 hunks)tests/streams/order_book/split_limit_order_test.go(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-07-14T18:18:20.905Z
Learnt from: outerlook
Repo: trufnetwork/node PR: 1055
File: extensions/tn_cache/internal/db_ops.go:40-43
Timestamp: 2025-07-14T18:18:20.905Z
Learning: The SetTx method in extensions/tn_cache/internal/db_ops.go is only used in tests that run sequentially, so concurrency concerns about race conditions don't apply to this method.
Applied to files:
tests/streams/order_book/sell_order_test.go
🧬 Code graph analysis (1)
tests/streams/order_book/split_limit_order_test.go (4)
tests/streams/utils/runner.go (1)
RunSchemaTest(37-116)internal/migrations/migration.go (1)
GetSeedScriptStatements(60-109)tests/streams/utils/utils.go (1)
GetTestOptionsWithCache(75-88)tests/streams/order_book/buy_order_test.go (1)
Position(399-406)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: acceptance-test
🔇 Additional comments (6)
tests/streams/order_book/sell_order_test.go (1)
254-258: Clarifying comment around test-only settlement looks goodThe added TODO block clearly documents that this UPDATE is a test-only shortcut and points to the future settlement action, which should help avoid confusion between test setup and production flows.
tests/streams/order_book/split_limit_order_test.go (5)
22-48: Test suite wiring and grouping are solidThe main
TestPlaceSplitLimitOrderharness is wired correctly intoRunSchemaTest, and the grouping into validation, success-path, and (future) matching tests makes the scenarios easy to navigate and extend.
138-255: Validation-path tests closely mirror on-chain error conditionsThe invalid price, invalid amount, and insufficient-balance tests exercise the key boundary cases (0/100/150 for
true_price, 0/negative/>1e9 foramount, and underfunded collateral), and theContainschecks for error text line up with the messages inplace_split_limit_order. This gives good confidence that the action’s guardrails behave as intended.
257-435: Success-path tests correctly assert YES/NO positions and UPSERT behaviorThe successful, multi-price, and same-price scenarios validate exactly what
place_split_limit_orderis supposed to do: accumulate a single YES holding at price 0, create NO sell orders at100-true_price, and rely on UPSERT behavior to merge amounts at identical price levels. The position-count and amount assertions match the schema (Position.Priceasint16,Amountasint64, perbuy_order_test.go) and the Kuneiform upsert logic.
437-482: Balance delta check matches the 1 TRUF-per-pair collateral designThe balance-change test for 75 pairs correctly expects a 75 TRUF decrease (using
toWei("75")and abig.Intdiff). This neatly ties the ERC20 bridge behavior to theamount × 10^18collateral formula in the SQL action and should catch any future drift in collateral calculation.
484-579: Position verification and helper invocation match the on-chain contractThe detailed position-verification test for the 35/65 split confirms both sides of the trade (YES holding @0, NO sell @65) with outcome and price checks, which aligns with
$false_price := 100 - $true_pricein the action. ThecallPlaceSplitLimitOrderhelper sets upTxContext/Engine.Callin the same style as existing buy/sell helpers, so it should integrate cleanly with the engine.
resolves: https://github.com/truflation/website/issues/2918
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.