Skip to content

test(drive): cover token transition action transformers and accessors#3505

Merged
QuantumExplorer merged 1 commit into
v3.1-devfrom
test/coverage-rs-drive-batch-token-actions
Apr 21, 2026
Merged

test(drive): cover token transition action transformers and accessors#3505
QuantumExplorer merged 1 commit into
v3.1-devfrom
test/coverage-rs-drive-batch-token-actions

Conversation

@QuantumExplorer
Copy link
Copy Markdown
Member

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 at packages/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 tests blocks — no integration harness required. Mirrors the pre-existing test pattern in token_direct_purchase_transition_action/v0/transformer.rs:299.

Per-target breakdown

Submodule Prev cov Missed Tests added
token_base_transition_action 53.67% 208 11
token_destroy_frozen_funds_transition_action 47.23% 181 13
token_mint_transition_action 57.14% 168 9
token_claim_transition_action 72.20% 149 24
token_burn_transition_action 57.24% 130 13
token_set_price_for_direct_purchase_transition_action 52.81% 126 10
token_direct_purchase_transition_action 62.54% 124 13 new (17 total)
token_emergency_action_transition_action 53.03% 124 10
token_freeze_transition_action 52.85% 124 11
token_unfreeze_transition_action 52.85% 124 10
token_config_update_transition_action 60.37% 107 13
token_transfer_transition_action 72.04% 92 19
token_transition_action_type.rs 0% 14 12

Notable coverage wins

token_base_transition_action — the data_contract_fetch_info Arc-sharing semantics (ref vs clone; strong_count), the CorruptedCodeExecution error branch on missing token position, and store_in_group/original_group_action extraction chains.

token_claim_transition_action — the biggest target in tests-per-file. Exercises PreProgrammed filter logic (future-timestamp exclusion, non-owner skipping, strict > boundary at now), distribution_after_last_paid fallback + range lookup + exhaustion triggering InvalidTokenClaimNoCurrentRewards, the wrong_claimant_error match for all three recipient types, TokenClaimTransitionActionV0::recipient() for PreProgrammed/Perpetual+ContractOwner/Perpetual+Identity/Perpetual+Evonode, EvonodesByParticipation RewardRatio closure (single-epoch, multi-epoch summation, empty-range None, zero-proposed owner), and last_paid_moment.unwrap_or(contract_creation_cycle_start) fallback.

token_direct_purchase_transition_action — expanded the existing 4 overflow tests with: SinglePrice exact/over/under/zero-price/zero-count payment paths, SetPrices tiered lookup (range matches highest applicable tier, exact boundary, count above all tiers, below-minimum triggering TokenAmountUnderMinimumSaleAmount + 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), TokenPricingSchedule SinglePrice/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 TokenTransitionAction variants mapped via TokenTransitionActionTypeGetter::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 — clean

No production bugs surfaced.

Breaking Changes

None. Tests only.

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

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>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

Warning

Rate limit exceeded

@QuantumExplorer has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 58 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 42a97302-d9bd-495f-a4f8-07c0653700fd

📥 Commits

Reviewing files that changed from the base of the PR and between 9e338b8 and 157728d.

📒 Files selected for processing (15)
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_base_transition_action/mod.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_base_transition_action/v0/mod.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_burn_transition_action/mod.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_claim_transition_action/v0/transformer.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_config_update_transition_action/mod.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/mod.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_direct_purchase_transition_action/v0/transformer.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_emergency_action_transition_action/v0/transformer.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_freeze_transition_action/v0/transformer.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_mint_transition_action/mod.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_mint_transition_action/v0/mod.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_set_price_for_direct_purchase_transition_action/v0/transformer.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_transfer_transition_action/v0/transformer.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_transition_action_type.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_unfreeze_transition_action/v0/transformer.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/coverage-rs-drive-batch-token-actions

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added this to the v3.1.0 milestone Apr 21, 2026
@thepastaclaw
Copy link
Copy Markdown
Collaborator

thepastaclaw commented Apr 21, 2026

Review Gate

Commit: 157728d6

  • Debounce: 103m ago (need 30m)

  • CI checks: builds passed, 0/2 tests passed

  • CodeRabbit review: comment found

  • Off-peak hours: peak window (5am-11am PT) — currently 08:11 AM PT Tuesday

  • Run review now (check to override)

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

❌ Patch coverage is 98.49108% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.45%. Comparing base (9e338b8) to head (157728d).
⚠️ Report is 1 commits behind head on v3.1-dev.

Files with missing lines Patch % Lines
...on/token_claim_transition_action/v0/transformer.rs 90.44% 28 Missing ⚠️
..._transition/token_base_transition_action/v0/mod.rs 98.76% 2 Missing ⚠️
...ition/token_config_update_transition_action/mod.rs 98.42% 2 Missing ⚠️
...irect_purchase_transition_action/v0/transformer.rs 98.93% 1 Missing ⚠️
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     
Components Coverage Δ
dpp 83.20% <ø> (+<0.01%) ⬆️
drive 85.05% <98.49%> (+0.33%) ⬆️
drive-abci 87.49% <ø> (ø)
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 92.10% <ø> (ø)
platform-wallet ∅ <ø> (∅)
drive-proof-verifier 55.66% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@QuantumExplorer QuantumExplorer merged commit 4355c15 into v3.1-dev Apr 21, 2026
71 of 72 checks passed
@QuantumExplorer QuantumExplorer deleted the test/coverage-rs-drive-batch-token-actions branch April 21, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants