test(drive): cover token transition action transformers and accessors#3505
Conversation
Add 168 new unit tests targeting the lowest-coverage files under packages/rs-drive/src/state_transition_action/batch/batched_transition/ token_transition/, which was 67% covered with 1,823 missed lines. Per-target summary (previous coverage → now exercised): - token_base_transition_action (54%): V0 accessor impl including data_contract_fetch_info Arc-sharing semantics, the CorruptedCodeExecution error branch on missing token position, and store_in_group/original_group_action extraction chains. 11 tests. - token_mint_transition_action (57%): V0 getters/setters, public_note owned-move, base_owned consume, enum wrapper match arms. 9 tests. - token_burn_transition_action (57%): V0 accessors, enum wrapper From/delegations (token_position/token_id/data_contract_id/ identity_contract_nonce). 13 tests. - token_destroy_frozen_funds_transition_action (47%): V0 accessors + enum wrapper. 13 tests. - token_config_update_transition_action (60%): V0 accessors + enum wrapper, exercise multiple TokenConfigurationChangeItem variants. 13 tests. - token_claim_transition_action (72%): PreProgrammed filter boundary/owner/timestamp logic, distribution_after_last_paid first_key_value fallback + range lookup + exhaustion, wrong_claimant match for ContractOwner/Identity/EvonodesByParticipation, TokenClaimTransitionActionV0::recipient() all three info variants, EvonodesByParticipation RewardRatio closure (single/multi-epoch, empty-range, zero-proposed), last_paid_moment fallback, and From<&TokenDistributionResolvedRecipient> round-trip. 24 tests. - token_set_price_for_direct_purchase_transition_action (53%): change_note.unwrap_or(public_note) rule (all four combinations plus clone), TokenPricingSchedule SinglePrice/SetPrices/None clone, V0 construction, From<V0> conversion. 10 tests. - token_direct_purchase_transition_action (63%): SinglePrice exact/ over/under/zero-price/zero-count, SetPrices tiered lookup (range matches highest applicable tier, exact boundary, count above all tiers, below-minimum triggers TokenAmountUnderMinimumSaleAmount), underpayment gate, free-tier acceptance. 13 new (17 total w/ 4 pre- existing overflow tests). - token_emergency_action_transition_action (53%): V0 accessors + Pause/Resume swap + paused() helper, enum wrapper. 10 tests. - token_freeze_transition_action (53%): V0 accessors, identity_to_ freeze_id set/get, non-zero token_position propagation, enum wrapper. 11 tests. - token_unfreeze_transition_action (53%): V0 accessors, frozen_ identity_id set/get, enum wrapper. 10 tests. - token_transfer_transition_action (72%): V0 amount/recipient/shared- and-private-encrypted-notes/notes() bundle round-trips and clearing, enum wrapper. 19 tests. - token_transition_action_type.rs (0%): all 11 TokenTransitionAction variants → action_type() mapping + uniqueness assertion. 12 tests. No production bugs surfaced. All 171 tests pass (cargo test -p drive state_transition_action::batch::batched_transition:: token_transition). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 9 minutes and 58 seconds. ⌛ 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: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (15)
✨ 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 |
Review GateCommit:
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## v3.1-dev #3505 +/- ##
============================================
+ Coverage 85.30% 85.45% +0.14%
============================================
Files 2476 2476
Lines 270705 272892 +2187
============================================
+ Hits 230938 233187 +2249
+ Misses 39767 39705 -62
🚀 New features to boost your workflow:
|
Issue being fixed or feature implemented
Third PR in the push toward 90% global coverage (now at 85.30% after #3503 and #3504). Targets the single largest gap cluster in
rs-drive: the token transition action transformers/accessors atpackages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/, which was 67% covered with 1,823 missed lines.What was done?
168 new unit tests added inline across 15 files (13 action submodules +
token_transition_action_type.rs). All inline#[cfg(test)] mod testsblocks — no integration harness required. Mirrors the pre-existing test pattern in token_direct_purchase_transition_action/v0/transformer.rs:299.Per-target breakdown
token_base_transition_actiontoken_destroy_frozen_funds_transition_actiontoken_mint_transition_actiontoken_claim_transition_actiontoken_burn_transition_actiontoken_set_price_for_direct_purchase_transition_actiontoken_direct_purchase_transition_actiontoken_emergency_action_transition_actiontoken_freeze_transition_actiontoken_unfreeze_transition_actiontoken_config_update_transition_actiontoken_transfer_transition_actiontoken_transition_action_type.rsNotable coverage wins
token_base_transition_action — the
data_contract_fetch_infoArc-sharing semantics (ref vs clone; strong_count), theCorruptedCodeExecutionerror branch on missing token position, andstore_in_group/original_group_actionextraction chains.token_claim_transition_action — the biggest target in tests-per-file. Exercises PreProgrammed filter logic (future-timestamp exclusion, non-owner skipping, strict
>boundary atnow),distribution_after_last_paidfallback + range lookup + exhaustion triggeringInvalidTokenClaimNoCurrentRewards, thewrong_claimant_errormatch for all three recipient types,TokenClaimTransitionActionV0::recipient()for PreProgrammed/Perpetual+ContractOwner/Perpetual+Identity/Perpetual+Evonode, EvonodesByParticipationRewardRatioclosure (single-epoch, multi-epoch summation, empty-range None, zero-proposed owner), andlast_paid_moment.unwrap_or(contract_creation_cycle_start)fallback.token_direct_purchase_transition_action — expanded the existing 4 overflow tests with:
SinglePriceexact/over/under/zero-price/zero-count payment paths,SetPricestiered lookup (range matches highest applicable tier, exact boundary, count above all tiers, below-minimum triggeringTokenAmountUnderMinimumSaleAmount+keys().next()threshold), underpayment gate (TokenDirectPurchaseUserPriceTooLow), free-tier acceptance.token_set_price_for_direct_purchase_transition_action — exhaustive coverage of the
change_note.unwrap_or(public_note)rule (all four Some/None combinations plus clone),TokenPricingScheduleSinglePrice/SetPrices(BTreeMap)/None clone semantics, V0 construction +From<V0>enum-wrapper conversion.token_transfer_transition_action — V0
notes()bundle round-trips (shared_encrypted_note, private_encrypted_note, transfer note), amount/recipient_id set/get, clearing individual notes, enum wrapper match-arm dispatch.token_transition_action_type.rs (0% → covered) — every one of the 11
TokenTransitionActionvariants mapped viaTokenTransitionActionTypeGetter::action_type(), plus a uniqueness assertion across all mapped types.How Has This Been Tested?
cargo test -p drive --lib 'state_transition_action::batch::batched_transition::token_transition'— 171 passed (168 new + 3 pre-existing)cargo check --tests -p drive— clean (no new warnings)cargo fmt -p drive— cleanNo production bugs surfaced.
Breaking Changes
None. Tests only.
Checklist
For repository code-owners and collaborators only