test(drive-abci): fix direct-selling tests broken by empty-schedule validation#3876
Conversation
…alidation PRs #3856 and #3865 merged independently and conflict semantically: #3856 added tests that plant an empty SetPrices schedule via a state transition, while #3865 now rejects that transition at structure validation with TokenPricingScheduleEmptyError. Update the tests to assert the new upfront rejection, plant the empty schedule directly through the drive API to keep the transformer defense-in-depth regression coverage, and use a non-empty tiered schedule in the multi-token pricing test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR refactors token direct-selling tests to validate SetPrices schedule handling. A test helper is refactored to expose state transition results, test data is corrected to use valid pricing, and a regression test is rewritten to assert empty schedule rejection and verify downstream defensive error handling. ChangesToken SetPrices Validation Tests
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
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 docstrings
🧪 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 |
|
✅ Review complete (commit 04b0755) |
thepastaclaw
left a comment
There was a problem hiding this comment.
Code Review
Test-only PR that aligns with the new empty-SetPrices structure validation (#3865) and preserves the transformer defense-in-depth regression by planting the empty schedule directly through the drive API. Scope is minimal and correct. The agent findings either describe pre-existing test gaps unrelated to this PR's goal, or benign nitpicks not worth blocking on.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v3.1-dev #3876 +/- ##
=============================================
+ Coverage 70.82% 87.22% +16.39%
=============================================
Files 20 2641 +2621
Lines 2797 328569 +325772
=============================================
+ Hits 1981 286597 +284616
- Misses 816 41972 +41156
🚀 New features to boost your workflow:
|
Issue being fixed or feature implemented
CI on
v3.1-devis red: two drive-abci direct-selling tests fail withTokenPricingScheduleEmptyErrorwhere they expectSuccessfulExecution(e.g. this run).This is a semantic conflict between two independently merged PRs:
SetPricespricing schedule via a state transition, asserting it is accepted and stored (regression coverage for the direct-purchase transformer panic).TokenPricingScheduleEmptyError.Each PR was green on its own; together the #3856 tests can no longer plant their fixture.
What was done?
Test-only changes in
batch/tests/token/direct_selling/mod.rs— no production code touched:create_token_with_pricinghelper: a newcreate_token_with_pricing_resultreturns the set-price processing result, while the existing helper keeps asserting success on top of it.test_direct_purchase_empty_set_prices_does_not_panicnow covers both layers of the defense:SetPricesschedule via a state transition is rejected withUnpaidConsensusError(TokenPricingScheduleEmptyError)(the fix(dpp): reject empty token pricing schedules to prevent a direct-purchase chain halt #3865 check, end-to-end);Drive::token_set_direct_purchase_price(bypassing validation, simulating state written before the check existed) and asserts a purchase is still rejected gracefully asTokenNotForDirectSalewith no panic and no token credited (the fix(drive): return error instead of panicking on empty SetPrices direct purchase #3856 transformer fix).test_successful_direct_purchase_multiple_tokensuses a non-empty single-tierSetPricesschedule for its third token instead of the no-longer-storable empty one, keeping three distinct schedule shapes for the price fetch/proof round-trip.How Has This Been Tested?
cargo test -p drive-abci --all-features token_selling_tests— all 10 tests pass, including the two that were failing in CI. Also verified these are the only two places in the workspace (outside the #3865 validator's own unit tests) that construct an emptySetPricesschedule.Breaking Changes
None.
Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests