Skip to content

test(dpp): cover state transitions, token config, perpetual distribution - #3512

Merged
QuantumExplorer merged 1 commit into
v3.1-devfrom
test/coverage-state-transitions-and-token-config
Apr 21, 2026
Merged

test(dpp): cover state transitions, token config, perpetual distribution#3512
QuantumExplorer merged 1 commit into
v3.1-devfrom
test/coverage-state-transitions-and-token-config

Conversation

@QuantumExplorer

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Sixth PR in the push toward 90% global coverage. After #3503#3511, we're at 86.38%. This PR targets ~2,550 missed lines across the largest remaining gaps in rs-dpp.

What was done?

363 new unit tests across 27 files.

TargetPrev covMissedTests added
data_contract/associated_token/token_configuration/methods62%48460
data_contract/associated_token/token_perpetual_distribution/reward_distribution_moment65%12441
data_contract/associated_token/token_perpetual_distribution/reward_distribution_type56%9028
data_contract/associated_token/token_configuration_item.rs54%11224
data_contract/associated_token/token_configuration/v079%5538
state_transitions/document/batch_transition (action_type + resolvers + validation)79%86733
state_transitions/identity/identity_topup_from_addresses69%7717
state_transitions/identity/identity_create_from_addresses78%7116
state_transitions/identity/identity_credit_withdrawal (v0+v1)89%7310
state_transitions/identity/identity_create_transition84%537
state_transitions/identity/public_key_in_creation84%1206
state_transitions/identity/identity_credit_transfer_* (both variants)74–78%1598
state_transitions/shielded/* (4 transitions)68–74%31825
state_transitions/address_funds/address_funding_from_asset_lock84%8811

Highlighted coverage wins

token_configuration/methods (+60 tests) — every enum arm of apply_token_configuration_item, authorized_action_takers special-case NoOne returns for TokenConfigurationNoChange + MainControlGroup, can_apply allow/deny matrices across all rule categories, validate_token_configuration_groups_existGroupPositionDoesNotExistError + MainGroupIsNotDefinedError paths.

token_configuration_item.rs (+24 tests) — payload_serialization byte layout for MaxSupply/MainControlGroup BE, Identity 32 bytes, MintingAllowChoosingDestination bool-as-u8, Conventions bincode roundtrip, tag-byte sharing across all 24 AuthorizedActionTakers variants.

reward_distribution_moment (+41 tests)Add<u64> / Add<Self> / Div<u64> / Div<Self> full variant matrix including overflow, type-mismatch AddingDifferentTypes, u16 rhs cap, zero-divisor DivideByZero, epoch from_block_info.

reward_distribution_type (+28 tests)moment_from_bytes 5 decode-error arms, max_cycle_moment non-fixed path with MAX_DISTRIBUTION_CYCLES_PARAM vs max_non_fixed_amount_cycles and epoch current-1 saturation, validate_structure_interval_v0 Mainnet/Testnet/Regtest block-too-short + time-not-minute-aligned error paths.

batch_transition (+33 tests) — resolver match-arm coverage for BatchedTransition + BatchedTransitionRef (14 Document→None + 11 token→value per trait), find_duplicates_by_id three-way collision pushes_pairs quirk, validate_basic_structure consensus errors (DocumentTransitionsAreAbsent, MaxDocumentsTransitionsExceeded, NonceOutOfBounds).

identity_topup_from_addresses (+17 tests) + identity_create_from_addresses (+16 tests) — full validate_structure branch coverage: no_inputs, witness/input mismatch, output_is_input, fee_strategy_empty/duplicate/out_of_bounds, input/output below minimum, input_sum_less_than_required, overflow, MissingMasterPublicKey, MaxIdentityPublicKeyLimitReached.

shielded transitions (+25 tests across 4 transitions) — StateTransitionLike surface (type/version/modified_ids/unique_identifiers via base64-of-asset-lock or hex-of-nullifier), signature setters, AssetLockProved accessor+setter, FeatureVersioned.

address_funding_from_asset_lock (+11 tests) — full StateTransitionLike + SingleSigned + WitnessSigned + UserFeeIncrease + Signable shadow From conversion.

How Has This Been Tested?

  • cargo test -p dpp --lib 'state_transitions::identity' — 272 pass
  • cargo test -p dpp --lib 'batch_transition' — 250 pass
  • cargo test -p dpp --lib 'token_configuration' — 157 pass
  • cargo test -p dpp --lib 'state_transitions::shielded' — 99 pass
  • cargo test -p dpp --lib 'token_perpetual_distribution' — 405 pass
  • cargo test -p dpp --lib 'state_transitions::address_funds' — 90 pass
  • cargo check --tests -p dpp — clean
  • cargo fmt -p dpp — clean

No production bugs surfaced. One design quirk pinned by test for regression detection: find_duplicates_by_id three-way collisions push (existing, new) for each subsequent collision, producing 4 entries for a triple-duplicate instead of 3.

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

…stribution
Add 363 new unit tests across 27 files targeting the largest
remaining gaps in rs-dpp (token config methods, document batch
transitions, identity transitions, shielded transitions, reward
distribution types/moments).
Per-target breakdown (previous coverage → now exercised):
- state_transition/state_transitions/document/batch_transition
(79% → covered, 33 tests): action-type TryFrom error messages
across document + token enums, resolver match-arm coverage for
BatchedTransition and BatchedTransitionRef (14 Document(_)=>None
+ 11 token => value arms per trait), find_duplicates_by_id
fingerprint specificity + three-way collision pushes_pairs
quirk, validate_basic_structure DocumentTransitionsAreAbsent +
MaxDocumentsTransitionsExceeded + NonceOutOfBounds consensus
errors.
- data_contract/associated_token/token_configuration/methods
(62% → covered, 60 tests across 4 submodules): every enum arm
of apply_token_configuration_item (23 tests),
authorized_action_takers special-case NoOne returns for
TokenConfigurationNoChange + MainControlGroup (15 tests),
can_apply_token_configuration_item allow/deny across all rule
categories (15 tests), validate_token_configuration_groups_exist
GroupPositionDoesNotExistError + MainGroupIsNotDefinedError
paths (7 tests).
- data_contract/associated_token/token_configuration_item.rs
(54% → covered, 24 tests): payload_serialization byte layout
for MaxSupply/MainControlGroup BE, Identity 32 bytes,
MintingAllowChoosingDestination bool-as-u8, Conventions bincode
roundtrip, tag-byte sharing across all 24
AuthorizedActionTakers variants, Display + equality per arm.
- data_contract/associated_token/token_configuration/v0
(79% → covered, 38 tests): TokenConfigurationPreset default_*
helpers across all 5 TokenConfigurationPresetFeatures variants,
default_distribution_rules with direct-pricing on/off,
default_most_restrictive, all_used_group_positions Group variant
collection + MainGroup flag + main_control_group inclusion.
- data_contract/associated_token/token_perpetual_distribution/
reward_distribution_moment (65% → covered, 41 tests): to_u64,
same_type, cycle_start (aligned/unaligned/zero-step + type
mismatch), Add<u64> (all variants + overflow + u16 rhs cap),
Add<Self> (all variants + overflow + type mismatch), Div<u64>
(zero rhs, over-u16, ok), Div<Self> (zero + type mismatch),
PartialEq<u64/u32/u16/usize>, to_be_bytes_vec, Display,
from_block_info, steps_till edge cases.
- data_contract/associated_token/token_perpetual_distribution/
reward_distribution_type (56% → covered, 28 tests):
moment_from_bytes 5 decode-error arms + 3 success arms,
max_cycle_moment capped-by-current + non-fixed + epoch current-1
saturation, validate_structure_interval_v0 block-too-short
Mainnet / Testnet / Regtest + time boundary + not-minute-aligned
error paths.
- state_transitions/identity/public_key_in_creation (84% →
covered, 6 tests): StateTransitionValueConvert dispatch +
version errors, canonical_object inserts $version, value_map
roundtrip, default_versioned unknown-version, duplicate-keys
witness invariant.
- state_transitions/identity/identity_topup_from_addresses
(69% → covered, 17 tests): full validate_structure branch
coverage — no_inputs, witness_count_mismatch, output_is_input,
fee_strategy_empty/duplicate/out_of_bounds, input_below_minimum,
output_below_minimum, input_sum_less_than_required, overflow.
- state_transitions/identity/identity_create_from_addresses
(78% → covered, 16 tests): full validate_structure branch
coverage — no_inputs, no_public_keys (MissingMasterPublicKey),
too_many_public_keys (MaxIdentityPublicKeyLimit), input/witness
mismatch, fee_strategy bounds, input/output below minimum,
input_sum_less_than_required, overflow_on_input_sum.
- state_transitions/identity/identity_create_transition
(84% → covered, 7 tests): try_from_inner ChainAssetLockProof
identity_id derivation, AssetLockProved::set_asset_lock_proof,
accessors, dispatch, versioning.
- state_transitions/identity/identity_credit_withdrawal_transition
(89% → covered, 10 tests v0+v1): skip_signature removal across
to_object / to_cleaned_object / to_canonical_cleaned_object,
Pooling::Never vs Standard roundtrip, v1 None-output_script
value_map roundtrip.
- state_transitions/identity/identity_credit_transfer_transition
+ identity_credit_transfer_to_addresses (74/78% → covered,
8 tests): skip_signature path removal, modified_data_ids +
unique_identifiers, validate_structure NoRecipients / too_many /
recipient_below_minimum / single-valid.
- state_transitions/shielded/* (68-74% → covered, 25 tests across
shield_from_asset_lock / shielded_withdrawal / unshield /
shielded_transfer): StateTransitionLike type/version/
modified_ids/unique_identifiers (base64 of asset lock or hex
of nullifier), signature + FeatureVersioned + AssetLockProved
accessors.
- state_transitions/address_funds/address_funding_from_asset_lock
(84% → covered, 11 tests): full StateTransitionLike surface,
SingleSigned + WitnessSigned setters, UserFeeIncrease get/set,
Signable shadow From conversion.
All 363 tests pass. No production bugs surfaced. One design quirk
noted in find_duplicates_by_id — three-way collisions push
(existing, new) for each subsequent collision, producing 4 entries
for a triple-duplicate; pinned by test for regression detection.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actionsgithub-actionsBot added this to the v3.1.0 milestone Apr 21, 2026
@coderabbitai

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@QuantumExplorer has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 47 minutes and 5 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 47 minutes and 5 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: 223837b1-5d32-45d1-8abd-7184e6c2a664

📥 Commits

Reviewing files that changed from the base of the PR and between f038dac and 6ee7b0a.

📒 Files selected for processing (27)
  • packages/rs-dpp/src/data_contract/associated_token/token_configuration/methods/apply_token_configuration_item/v0/mod.rs
  • packages/rs-dpp/src/data_contract/associated_token/token_configuration/methods/authorized_action_takers_for_configuration_item/v0/mod.rs
  • packages/rs-dpp/src/data_contract/associated_token/token_configuration/methods/can_apply_token_configuration_item/v0/mod.rs
  • packages/rs-dpp/src/data_contract/associated_token/token_configuration/methods/validate_token_configuration_groups_exist/v0/mod.rs
  • packages/rs-dpp/src/data_contract/associated_token/token_configuration/v0/mod.rs
  • packages/rs-dpp/src/data_contract/associated_token/token_configuration_item.rs
  • packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/reward_distribution_moment/mod.rs
  • packages/rs-dpp/src/data_contract/associated_token/token_perpetual_distribution/reward_distribution_type/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/address_funds/address_funding_from_asset_lock_transition/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/document_transition_action_type.rs
  • packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/resolvers.rs
  • packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/batched_transition/token_transition_action_type.rs
  • packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/validation/find_duplicates_by_id/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/document/batch_transition/validation/validate_basic_structure/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_from_addresses_transition/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/identity/identity_create_transition/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_to_addresses_transition/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_to_addresses_transition/v0/state_transition_validation.rs
  • packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_transfer_transition/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/identity/identity_credit_withdrawal_transition/v1/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/identity/identity_topup_from_addresses_transition/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/identity/public_key_in_creation/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/shield_from_asset_lock_transition/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/shielded_transfer_transition/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/shielded_withdrawal_transition/v0/mod.rs
  • packages/rs-dpp/src/state_transition/state_transitions/shielded/unshield_transition/v0/mod.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/coverage-state-transitions-and-token-config

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.

@thepastaclaw

thepastaclaw commented Apr 21, 2026

Copy link
Copy Markdown
Collaborator

Review Gate

Commit: 6ee7b0ad

  • Debounce: 28m ago (need 30m)

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

  • CodeRabbit review: comment found

  • Off-peak hours: off-peak (02:42 PM PT Tuesday)

  • Run review now (check to override)

@codecov

codecovBot commented Apr 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.26145% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.77%. Comparing base (f038dac) to head (6ee7b0a).
⚠️ Report is 1 commits behind head on v3.1-dev.

Files with missing linesPatch %Lines
...tion/validation/validate_basic_structure/v0/mod.rs93.65%8 Missing ⚠️
...alidate_token_configuration_groups_exist/v0/mod.rs93.20%7 Missing ⚠️
...dress_funding_from_asset_lock_transition/v0/mod.rs98.07%2 Missing ⚠️
...ielded/shield_from_asset_lock_transition/v0/mod.rs96.92%2 Missing ⚠️
...thods/can_apply_token_configuration_item/v0/mod.rs99.62%1 Missing ⚠️
...tract/associated_token/token_configuration_item.rs99.61%1 Missing ⚠️
...etual_distribution/reward_distribution_type/mod.rs99.56%1 Missing ⚠️
...ched_transition/document_transition_action_type.rs96.00%1 Missing ⚠️
...batched_transition/token_transition_action_type.rs95.83%1 Missing ⚠️
...identity_topup_from_addresses_transition/v0/mod.rs99.55%1 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## v3.1-dev #3512 +/- ##
============================================
+ Coverage 86.37% 86.77% +0.39% 
============================================
Files 2474 2474 Lines 277856 281241 +3385 ============================================
+ Hits 240007 244048 +4041 + Misses 37849 37193 -656 
ComponentsCoverage Δ
dpp85.90% <99.26%> (+1.79%)⬆️
drive85.84% <ø> (ø)
drive-abci88.90% <ø> (ø)
sdk∅ <ø> (∅)
dapi-client∅ <ø> (∅)
platform-version∅ <ø> (∅)
platform-value92.10% <ø> (ø)
platform-wallet∅ <ø> (∅)
drive-proof-verifier55.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 c9cc329 into v3.1-devApr 21, 2026
102 of 105 checks passed
@QuantumExplorer
QuantumExplorer deleted the test/coverage-state-transitions-and-token-config branch April 21, 2026 21:44
Sign up for freeto 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

@QuantumExplorer@thepastaclaw