Skip to content

test: cover proof-verifier, batch token actions, identity conversions#3526

Merged
QuantumExplorer merged 6 commits into
v3.1-devfrom
test/coverage-proof-verifier-batch-actions
Apr 23, 2026
Merged

test: cover proof-verifier, batch token actions, identity conversions#3526
QuantumExplorer merged 6 commits into
v3.1-devfrom
test/coverage-proof-verifier-batch-actions

Conversation

@QuantumExplorer
Copy link
Copy Markdown
Member

@QuantumExplorer QuantumExplorer commented Apr 23, 2026

Issue being fixed or feature implemented

Improve code coverage for the three highest-leverage targets remaining after PR #3525:

  • rs-drive-proof-verifier (45% → higher, was biggest single-file gap)
  • rs-drive/src/state_transition_action/batch/batched_transition/token_transition/ (60-75% cov modules)
  • rs-dpp/src/identity/ zero-coverage conversion modules

What was done

Added 330 new unit tests across ~30 files. All tests are #[cfg(test)] additions — no production code was modified.

rs-drive-proof-verifier/src/proof.rs — 78 tests

  • Numeric helpers: try_u32_to_u16, u32_to_u16_opt boundary behavior
  • Length / IntoOption trait impl edge cases (None, empty, only-None BTreeMap, absence markers)
  • parse_key_request_type negative/empty/missing branches
  • FromProof wrapper methods (from_proof_with_metadata, maybe_from_proof) success + NotFound mapping
  • Per-impl decode-stage error paths across Identity, IdentityBalance, DataContract, AddressInfo, EpochInfo, ProtocolVersionUpgrades, Elements, IdentitiesContractKeys, PrefundedSpecializedBalance, ProposerBlockCounts, Shielded, Vote, BroadcastStateTransition

rs-drive-proof-verifier/src/proof/*.rs + from_request.rs + verify.rs — 57 tests

  • token_contract_info.rs (6), token_perpetual_distribution_last_claim.rs (8), token_pre_programmed_distributions.rs (7), groups.rs (13), identity_token_balance.rs (6), token_info.rs (6)
  • from_request.rs (21) — offset rejection for contested document queries, missing-version, bad identifiers, invalid bincode start_value, populated roundtrip
  • verify.rs (2) — ContextProvider::get_quorum_public_key error propagation, invalid 48-byte pubkey

rs-drive/src/state_transition_action/batch/batched_transition/token_transition/ — 129 tests

Seven token action modules (destroy_frozen_funds, set_price_for_direct_purchase, emergency_action, unfreeze, freeze, config_update, direct_purchase), covering:

  • Enum accessor/mutator tests in each mod.rs
  • V0 struct tests where none existed
  • Transformer logic fragments: change_note.unwrap_or(public_note) precedence, owned vs borrowed cloning, TokenConfigurationChangeItem variant clone roundtrips, TokenPricingSchedule variant cloning, destructure patterns

Does NOT cover full try_from_* transformer bodies — those require a live Drive/GroveDB, matching the sibling token_mint/token_transfer pattern.

rs-dpp/src/identity/ — 66 tests

  • identity.rs (10) — default_versioned, new_with_id_and_keys, into_partial_identity_info, hash stability, deterministic ID, empty-inputs error
  • identity_facade.rs (13) — new, create, create_chain_asset_lock_proof, create_instant_lock_proof, create_from_buffer, 6 state-transition helpers
  • conversion/platform_value/mod.rs (6) — TryFromPlatformVersioned<Value> happy + garbage, to_cleaned_object
  • v0/conversion/json.rs (6) + v0/conversion/platform_value.rs (5) — including 2 frozen: V0 consensus behavior lock-ins documenting pre-existing serialization asymmetries
  • identity_public_key/conversion/{json,platform_value}/mod.rs (4+5) — delegation to V0, roundtrip, missing-fields error
  • identity_public_key/v0/conversion/{json,platform_value}.rs (8+9) — roundtrips, non-map error, contract-bounds roundtrip, canonical JSON, bad base64

Frozen V0 behaviors documented (not fixed)

Per project convention, pre-existing V0 serialization asymmetries are locked in with // frozen: V0 consensus behavior rather than modified:

  1. IdentityV0::to_objectTryFrom<Value> roundtrip fails because platform_value::to_value emits BinaryData as Value::Bytes while inner deserializers default to human-readable and expect base64 strings.
  2. IdentityV0::from_json cannot ingest the canonical legacy fixture because it lacks the $formatVersion adjacency tag required by the serde-tagged IdentityPublicKey enum.

How Has This Been Tested?

cargo fmt --all --check
cargo check --tests -p drive-proof-verifier -p drive -p dpp
cargo test -p drive-proof-verifier --lib    # 217 passed
cargo test -p drive --lib state_transition_action::batch::batched_transition::token_transition    # 300 passed
cargo test -p dpp --lib identity    # 612 passed
cargo test -p dpp --features client --lib identity    # 639 passed

Breaking Changes

None — tests only. No production code modified.

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 made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • Tests
    • Added comprehensive unit test coverage across identity conversion, proof verification, and token transition modules to validate correctness of core platform behaviors, error handling, and edge cases.
    • Enhanced test suites ensure improved stability and reliability across serialization/deserialization, request validation, and state transition processing.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 23, 2026

Warning

Rate limit exceeded

@QuantumExplorer has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 30 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 20 minutes and 30 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: 99ebac77-2e69-4a09-bd61-9e78a3c41af6

📥 Commits

Reviewing files that changed from the base of the PR and between b50f76b and a50faac.

📒 Files selected for processing (8)
  • packages/rs-dpp/src/identity/conversion/platform_value/mod.rs
  • packages/rs-drive-proof-verifier/src/proof.rs
  • packages/rs-drive-proof-verifier/src/proof/token_contract_info.rs
  • packages/rs-drive-proof-verifier/src/proof/token_pre_programmed_distributions.rs
  • packages/rs-drive-proof-verifier/src/verify.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_unfreeze_transition_action/v0/transformer.rs
📝 Walkthrough

Walkthrough

This PR adds comprehensive unit test coverage for identity conversions, proof verification, and token state transition actions. Tests validate serialization/deserialization roundtrips, accessor/mutator behavior, error handling for invalid inputs, and delegation patterns without modifying any public API declarations.

Changes

Cohort / File(s) Summary
Identity Core & Facade Tests
packages/rs-dpp/src/identity/identity.rs, packages/rs-dpp/src/identity/identity_facade.rs
Tests for Identity constructors, conversion helpers, partial identity info creation, hashing, and state-transition id derivation. Facade tests verify factory methods, lock proof creation, and serialization roundtrips with feature-gated state-transition validation.
Identity Conversion - Platform Value
packages/rs-dpp/src/identity/conversion/platform_value/mod.rs, packages/rs-dpp/src/identity/v0/conversion/platform_value.rs
Tests for identity platform-value deserialization from legacy v0 shapes, to_cleaned_object() retention of format tags, public key disabledAt field omission logic, and v0 frozen behavior preventing roundtrip deserialization.
Identity Conversion - JSON
packages/rs-dpp/src/identity/v0/conversion/json.rs
Tests validating v0 JSON serialization shape (format version, identifier encoding), roundtrip failures for binary data, rejection of legacy fixture JSON, and error handling for invalid identifiers and malformed key arrays.
Identity Public Key Conversions
packages/rs-dpp/src/identity/identity_public_key/conversion/json/mod.rs, packages/rs-dpp/src/identity/identity_public_key/conversion/platform_value/mod.rs
Tests for public key JSON/platform-value conversions, delegation to v0 variants, conditional disabledAt field handling, roundtrip serialization, and error cases for incomplete/invalid input.
Identity Public Key V0 Conversions
packages/rs-dpp/src/identity/identity_public_key/v0/conversion/json.rs, packages/rs-dpp/src/identity/identity_public_key/v0/conversion/platform_value.rs
Tests for v0 public key JSON serialization (field presence, binary encoding, disabled status), roundtrip conversions with TryFrom/TryInto, error handling for invalid JSON/non-base64 data, and platform-value map serialization with optional contract_bounds.
Proof Request Conversion Tests
packages/rs-drive-proof-verifier/src/from_request.rs
Tests validating rejection of internal offset fields in drive queries, missing version errors, malformed request field byte-length validation, roundtrip serialization for vote poll queries, and bincode decoding error paths.
Core Proof Verification Tests
packages/rs-drive-proof-verifier/src/proof.rs
Extensive tests for numeric conversion helpers, Length/IntoOption edge cases, key request type parsing, FromProof implementations with happy-path metadata/proof validation, and error propagation for malformed state-transition scenarios.
Proof Group Conversions
packages/rs-drive-proof-verifier/src/proof/groups.rs
Tests for Group/GroupActions FromProof conversions, validation of missing request versions, invalid identifier/status conversions, missing response metadata, and UnreachableProvider verification to ensure early failure without provider access.
Proof Token & Identity Balance Tests
packages/rs-drive-proof-verifier/src/proof/identity_token_balance.rs, packages/rs-drive-proof-verifier/src/proof/token_contract_info.rs, packages/rs-drive-proof-verifier/src/proof/token_info.rs
Tests for identity/token balance request validation (missing versions, byte-length errors), token contract info proof conversion (invalid token_id, missing metadata/proof), and token info proofs covering both single and multi-identity query variants.
Proof Token Distribution Tests
packages/rs-drive-proof-verifier/src/proof/token_perpetual_distribution_last_claim.rs, packages/rs-drive-proof-verifier/src/proof/token_pre_programmed_distributions.rs
Tests for distribution claim conversion (invalid id lengths, missing proof/metadata, provider fallback), and preprogrammed distribution request validation (malformed recipient, limit boundary at u16::MAX).
Proof Verification Quorum Tests
packages/rs-drive-proof-verifier/src/verify.rs
Tests for tenderdash proof verification with invalid/all-zero quorum public keys, validating proper error propagation and handling of downstream public key/signature failures.
Token Config Update Action Tests
packages/rs-drive/src/state_transition_action/.../token_config_update_transition_action/v0/mod.rs, .../token_config_update_transition_action/v0/transformer.rs
Tests for config update accessor/mutator behavior (configuration items, public notes), base action delegation, and transformer note-merging precedence (change_note override semantics).
Token Destroy Frozen Funds Action Tests
packages/rs-drive/src/state_transition_action/.../token_destroy_frozen_funds_transition_action/v0/mod.rs, .../token_destroy_frozen_funds_transition_action/v0/transformer.rs
Tests for frozen funds action getters/setters (frozen identity id, amount including boundary values), public note handling, base delegation, and transformer note-merging with error wrapping validation.
Token Direct Purchase Action Tests
packages/rs-drive/src/state_transition_action/.../token_direct_purchase_transition_action/mod.rs, .../token_direct_purchase_transition_action/v0/mod.rs
Tests for enum variant wrapping, base delegation, token count/agreed price mutators (mutual independence), and Arc pointer equality for data contract fetch info.
Token Emergency Action Tests
packages/rs-drive/src/state_transition_action/.../token_emergency_action_transition_action/mod.rs, .../token_emergency_action_transition_action/v0/transformer.rs
Tests for emergency action value retrieval, public note reference/owned behavior, transformer note-merging precedence with copy semantics for action deref, and clone preservation of original note.
Token Freeze Action Tests
packages/rs-drive/src/state_transition_action/.../token_freeze_transition_action/mod.rs, .../token_freeze_transition_action/v0/transformer.rs
Tests for freeze identity accessor/setter, public note mutation (set/clear), base delegation, and transformer note merging across all option shapes with deref/copy for identity field.
Token Set Price Action Tests
packages/rs-drive/src/state_transition_action/.../token_set_price_for_direct_purchase_transition_action/mod.rs, .../token_set_price_for_direct_purchase_transition_action/v0/mod.rs
Tests for price getter/setter (None/SinglePrice/SetPrices variants), public note reference/owned semantics, map equality for pricing schedules, base delegation, and Arc pointer equality.
Token Unfreeze Action Tests
packages/rs-drive/src/state_transition_action/.../token_unfreeze_transition_action/mod.rs, .../token_unfreeze_transition_action/v0/transformer.rs
Tests for frozen identity getter/setter, public note optional behavior, From enum wrapping, base delegation, transformer note-merging with 6 scenarios covering change_note presence/override/clear semantics.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

Poem

🐰 A warren of tests now guards each door,
With roundtrips, conversions, and so much more!
From tokens to proofs and identities bright,
Each case is covered—left, center, and right! 🎉
The code hops along, both tested and true,
A fuzzy-eared pledge: we've got proof for you!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main focus of the PR: adding test coverage for three distinct components (proof-verifier, batch token actions, and identity conversions).
Docstring Coverage ✅ Passed Docstring coverage is 88.38% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/coverage-proof-verifier-batch-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 23, 2026
@thepastaclaw
Copy link
Copy Markdown
Collaborator

thepastaclaw commented Apr 23, 2026

Review Gate

Commit: a50faacc

  • Debounce: 26m ago (need 30m)

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

  • CodeRabbit review: comment found

  • Off-peak hours: off-peak (04:18 AM PT Thursday)

  • Run review now (check to override)

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🧹 Nitpick comments (6)
packages/rs-drive-proof-verifier/src/from_request.rs (1)

1082-1093: Nit: misleading section header.

The header at Line 1083 reads bincode_encode_values: error path, but test_bincode_decode_mixed_valid_and_invalid actually exercises bincode_decode_values. Consider updating the comment to avoid confusing future readers.

Proposed tweak
-    // ---------------------------------------------------------------
-    // bincode_encode_values: error path
-    // ---------------------------------------------------------------
+    // ---------------------------------------------------------------
+    // bincode_decode_values: mixed valid/invalid error path
+    // ---------------------------------------------------------------
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/rs-drive-proof-verifier/src/from_request.rs` around lines 1082 -
1093, The section header comment "bincode_encode_values: error path" is
misleading for the test that exercises bincode_decode_values; update the comment
to accurately reflect that this block tests bincode_decode_values error handling
(e.g., change it to "bincode_decode_values: error path" or similar) so readers
can locate tests for bincode_decode_values and avoid confusion when inspecting
test_bincode_decode_mixed_valid_and_invalid.
packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_config_update_transition_action/v0/transformer.rs (1)

237-425: Note: many of these tests exercise only Option::unwrap_or / Clone, not the transformer.

The change_note.unwrap_or(public_note) tests, and the per-variant clone() round-trips of TokenConfigurationChangeItem, are essentially validating std library behavior and derived Clone impls rather than the transformer's logic. They add maintenance cost with limited defect-catching value — if either upstream variant layout changes, these need updating without reflecting a real regression in the transformer.

Consider consolidating into one or two parameterized assertions, or replacing with a true integration test against try_from_borrowed_token_config_update_transition_with_contract_lookup. Not blocking.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_config_update_transition_action/v0/transformer.rs`
around lines 237 - 425, The test module contains many small unit tests that only
verify standard library behavior (Option::unwrap_or) and derived Clone of
TokenConfigurationChangeItem (tests like config_update_change_note_* and the
per-variant clone round-trips), which bloats maintenance; consolidate these into
one or two parameterized tests that cover the change_note merging rule and Clone
round-trip, or remove them and add a focused integration test that exercises
try_from_borrowed_token_config_update_transition_with_contract_lookup end-to-end
to validate the transformer behavior; update the tests in the tests mod
(referencing functions/configs named config_update_change_note_*,
config_update_borrowed_note_clone_round_trip, and the
TokenConfigurationChangeItem clone tests) to either combine cases into a
table-driven test or replace them with an integration test that constructs
realistic inputs and asserts the transformer's outputs.
packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/v0/transformer.rs (2)

412-421: Move base instead of cloning it.

Line 420 clones base, but the original value is not used afterward. Moving it keeps the fixture simpler and avoids a potential redundant_clone clippy warning.

♻️ Proposed cleanup
         let value = TokenDestroyFrozenFundsTransitionV0 {
-            base: base.clone(),
+            base,
             frozen_identity_id: dpp::identifier::Identifier::new([0x07; 32]),
             public_note: Some("foo".to_string()),
         };

As per coding guidelines, “Follow rustfmt defaults and keep code clippy-clean for Rust modules”.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/v0/transformer.rs`
around lines 412 - 421, The test fixture creates `base` as a
TokenBaseTransition::V0 and then constructs `TokenDestroyFrozenFundsTransitionV0
{ base: base.clone(), ... }` which needlessly clones `base`; change the
constructor to move `base` instead of calling `clone()` (i.e., pass `base`
directly) and remove the unused clone, updating any variable ownership as needed
so `TokenBaseTransitionV0`, `TokenBaseTransition::V0`, and
`TokenDestroyFrozenFundsTransitionV0` use the moved value.

332-376: Tie these fragment tests to production code paths.

These tests currently re-check Option::unwrap_or, a locally constructed error wrapper, and the u64 alias bounds. They can still pass if the transformer’s real note-merge or error-construction code regresses. Consider extracting tiny private helpers for note resolution/error construction and calling those from both the transformer and tests, or use a fixture that invokes the actual branch under test.

Also applies to: 378-401, 444-453

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/v0/transformer.rs`
around lines 332 - 376, The tests are exercising Option::unwrap_or directly
instead of the transformer's real logic; extract a small private helper (e.g.
resolve_action_note(change_note: Option<Option<String>>, public_note:
Option<String>) -> Option<String>) and/or an error-construction helper used by
the transformer in
token_destroy_frozen_funds_transition_action::v0::transformer, call that helper
from the transform function, and update the unit tests
(change_note_some_some_takes_precedence_over_public_note,
change_note_some_none_clears_user_note, change_note_none_preserves_user_note,
both_none_yields_none, borrowed_branch_clones_public_note and the other
referenced tests) to invoke the helper or the real transformer code path instead
of calling unwrap_or directly so the tests fail if the production merge/error
logic regresses.
packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/v0/mod.rs (1)

187-190: Compare note refs as &str to avoid temporary String allocations.

Line 190 and Line 210 allocate Strings only for equality checks. Mapping the accessor result to &str keeps these assertions allocation-free and less likely to trip clippy/style checks.

♻️ Proposed cleanup
-        assert_eq!(v0.public_note(), Some(&"burning".to_string()));
+        assert_eq!(v0.public_note().map(String::as_str), Some("burning"));
@@
-        assert_eq!(v0.public_note(), Some(&"swapped".to_string()));
+        assert_eq!(v0.public_note().map(String::as_str), Some("swapped"));

As per coding guidelines, “Follow rustfmt defaults and keep code clippy-clean for Rust modules”.

Also applies to: 207-210

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/v0/mod.rs`
around lines 187 - 190, The tests v0_public_note_returns_ref_when_set (and the
similar test around lines 207-210) call make_v0 and compare v0.public_note() to
Some(&"burning".to_string()), causing temporary String allocations; change the
assertions to compare as &str by mapping the accessor result to an &str (e.g.,
assert_eq!(v0.public_note().map(|s| s.as_str()), Some("burning"))) so no
temporary String is created; locate uses of make_v0 and the public_note()
accessor in those test functions and update both assertions accordingly.
packages/rs-dpp/src/identity/identity_public_key/v0/conversion/json.rs (1)

128-130: Avoid the unnecessary Vec allocation in this assertion.

The pattern &vec![0xABu8; 33][..] allocates on the heap unnecessarily. Use an array slice directly to keep the test clippy-clean and idiomatic.

Suggested fix
         let key: IdentityPublicKeyV0 = s.as_str().try_into().expect("parse succeeds");
         assert_eq!(key.id, 7);
-        assert_eq!(key.data.as_slice(), &vec![0xABu8; 33][..]);
+        assert_eq!(key.data.as_slice(), [0xABu8; 33].as_slice());
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/rs-dpp/src/identity/identity_public_key/v0/conversion/json.rs`
around lines 128 - 130, The assertion unnecessarily allocates a Vec for the
expected bytes; change the RHS of the assertion comparing key.data.as_slice()
(from the test using IdentityPublicKeyV0 and key.id) to use a fixed array slice
or slice literal instead of &vec![0xABu8; 33][..], e.g. a reference to a [u8;33]
or a byte slice literal, so the comparison is performed against a
stack-allocated slice and removes the heap allocation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/rs-dpp/src/identity/conversion/platform_value/mod.rs`:
- Around line 99-110: The comment above the tagged_raw_value() helper is
misleading—update it to state that this fixture does NOT exactly mirror
IdentityV0::to_object(): it intentionally encodes nested `data` as a base64
string (because nested deserializer defaults to human-readable), so document
that difference and clarify that this shape is used for testing
try_from_platform_versioned rather than representing the raw to_object() bytes
output.

In `@packages/rs-drive-proof-verifier/src/proof.rs`:
- Around line 5809-5845: The test
broadcast_state_transition_empty_metadata_when_missing currently uses an invalid
state_transition (vec![0xFF;4]) which triggers Error::ProtocolError before
metadata is checked; replace that payload with a valid serialized state
transition (e.g. serialize a default/fixture StateTransition using the same
platform codec used in production) so
StateTransitionProofResult::maybe_from_proof proceeds to the metadata check and
the test can assert Error::EmptyResponseMetadata, or alternatively rename the
test to indicate it verifies deserialization failure; update the assertion to
expect Error::EmptyResponseMetadata when using the valid payload.

In `@packages/rs-drive-proof-verifier/src/proof/token_contract_info.rs`:
- Around line 256-259: The assertion currently accepts both
Error::EmptyResponseMetadata and Error::NoProofInResult which can hide a
regression in validation order; change the assert in token_contract_info.rs so
it only allows Error::EmptyResponseMetadata (remove Error::NoProofInResult from
the matches!), ensuring the test fails if metadata validation no longer
short-circuits before proof extraction.

In
`@packages/rs-drive-proof-verifier/src/proof/token_pre_programmed_distributions.rs`:
- Around line 323-358: The test limit_at_u16_max_does_not_error_on_conversion
currently relies on empty-proof Drive verification; instead call the
request-only conversion/validation path that checks metadata and request fields
(so the limit conversion is exercised) without performing proof/Drive
verification — e.g., invoke the conversion function on
GetTokenPreProgrammedDistributionsRequest directly (the same validation used by
TokenPreProgrammedDistributions conversion) rather than calling
TokenPreProgrammedDistributions::maybe_from_proof with response_with_proof and
UnreachableProvider; assert the conversion succeeds (or returns an error that is
not a RequestError containing "limit exceeds u16") for limit = u16::MAX and keep
references to GetTokenPreProgrammedDistributionsRequest,
TokenPreProgrammedDistributions, and the conversion function you locate (the
request-only validator/try_from/maybe_from_request) so the test no longer
depends on empty-proof Drive behavior.

In `@packages/rs-drive-proof-verifier/src/verify.rs`:
- Around line 501-512: The test around verify_tenderdash_proof should assert the
InvalidPublicKey path only: within the test that calls
verify_tenderdash_proof(&proof, &metadata, &[0u8; 32], &provider) (and captures
result.expect_err(...)), replace the broad assertion that accepts signature
errors with a strict check that the error corresponds to the public-key
validation failure (the PublicKey::try_from([0u8; 48]) failure). Concretely,
assert that err.to_string() (or the error variant) contains "invalid public key"
/ matches the InvalidPublicKey variant and remove the alternative branches
("Could not verify signature digest" and "empty signature") since the zero key
should trigger the PublicKey::try_from failure and the test uses a non-empty
signature.

In
`@packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_emergency_action_transition_action/v0/transformer.rs`:
- Around line 408-419: The test emergency_borrowed_copies_action_via_star_deref
uses the clippy-triggering pattern `*&pause`/`*&resume` which trips
clippy::deref_addrof; replace each `let copied = *&pause;` and `let copied =
*&resume;` with an intermediate reference binding (e.g. `let r = &pause; let
copied: TokenEmergencyAction = *r;`) or remove those redundant assertions
entirely since they only re-check TokenEmergencyAction: Copy; update the test
body in transformer.rs accordingly to avoid the deref_addrof lint while keeping
the same assertions.

In
`@packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_freeze_transition_action/v0/transformer.rs`:
- Around line 423-429: The test
freeze_borrowed_path_dereferences_identity_for_new_action_v0 contains a needless
addrof deref pattern `let copied = *&id;` which triggers clippy::deref_addrof;
fix it by replacing that line with a direct copy `let copied = id;` (or remove
the trivial test entirely if it adds no value), referencing the Identifier type
and the test function name so you locate the code path to change.

In
`@packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_unfreeze_transition_action/v0/transformer.rs`:
- Around line 404-410: The test
unfreeze_borrowed_path_dereferences_frozen_identity_id uses the `*&id` pattern
which triggers clippy::deref_addrof; update the test (or remove it) so it avoids
`*&`—for example, in the test function
unfreeze_borrowed_path_dereferences_frozen_identity_id bind a reference first
(e.g., `let r = &id; let copied: Identifier = *r;`) instead of `let copied =
*&id;`) or delete the test entirely since it only asserts Identifier: Copy and
does not exercise the transformer; ensure references to Identifier, copied and
the mirrored `frozen_identity_id` pattern are adjusted accordingly so the module
is clippy-clean.

---

Nitpick comments:
In `@packages/rs-dpp/src/identity/identity_public_key/v0/conversion/json.rs`:
- Around line 128-130: The assertion unnecessarily allocates a Vec for the
expected bytes; change the RHS of the assertion comparing key.data.as_slice()
(from the test using IdentityPublicKeyV0 and key.id) to use a fixed array slice
or slice literal instead of &vec![0xABu8; 33][..], e.g. a reference to a [u8;33]
or a byte slice literal, so the comparison is performed against a
stack-allocated slice and removes the heap allocation.

In `@packages/rs-drive-proof-verifier/src/from_request.rs`:
- Around line 1082-1093: The section header comment "bincode_encode_values:
error path" is misleading for the test that exercises bincode_decode_values;
update the comment to accurately reflect that this block tests
bincode_decode_values error handling (e.g., change it to "bincode_decode_values:
error path" or similar) so readers can locate tests for bincode_decode_values
and avoid confusion when inspecting test_bincode_decode_mixed_valid_and_invalid.

In
`@packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_config_update_transition_action/v0/transformer.rs`:
- Around line 237-425: The test module contains many small unit tests that only
verify standard library behavior (Option::unwrap_or) and derived Clone of
TokenConfigurationChangeItem (tests like config_update_change_note_* and the
per-variant clone round-trips), which bloats maintenance; consolidate these into
one or two parameterized tests that cover the change_note merging rule and Clone
round-trip, or remove them and add a focused integration test that exercises
try_from_borrowed_token_config_update_transition_with_contract_lookup end-to-end
to validate the transformer behavior; update the tests in the tests mod
(referencing functions/configs named config_update_change_note_*,
config_update_borrowed_note_clone_round_trip, and the
TokenConfigurationChangeItem clone tests) to either combine cases into a
table-driven test or replace them with an integration test that constructs
realistic inputs and asserts the transformer's outputs.

In
`@packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/v0/mod.rs`:
- Around line 187-190: The tests v0_public_note_returns_ref_when_set (and the
similar test around lines 207-210) call make_v0 and compare v0.public_note() to
Some(&"burning".to_string()), causing temporary String allocations; change the
assertions to compare as &str by mapping the accessor result to an &str (e.g.,
assert_eq!(v0.public_note().map(|s| s.as_str()), Some("burning"))) so no
temporary String is created; locate uses of make_v0 and the public_note()
accessor in those test functions and update both assertions accordingly.

In
`@packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/v0/transformer.rs`:
- Around line 412-421: The test fixture creates `base` as a
TokenBaseTransition::V0 and then constructs `TokenDestroyFrozenFundsTransitionV0
{ base: base.clone(), ... }` which needlessly clones `base`; change the
constructor to move `base` instead of calling `clone()` (i.e., pass `base`
directly) and remove the unused clone, updating any variable ownership as needed
so `TokenBaseTransitionV0`, `TokenBaseTransition::V0`, and
`TokenDestroyFrozenFundsTransitionV0` use the moved value.
- Around line 332-376: The tests are exercising Option::unwrap_or directly
instead of the transformer's real logic; extract a small private helper (e.g.
resolve_action_note(change_note: Option<Option<String>>, public_note:
Option<String>) -> Option<String>) and/or an error-construction helper used by
the transformer in
token_destroy_frozen_funds_transition_action::v0::transformer, call that helper
from the transform function, and update the unit tests
(change_note_some_some_takes_precedence_over_public_note,
change_note_some_none_clears_user_note, change_note_none_preserves_user_note,
both_none_yields_none, borrowed_branch_clones_public_note and the other
referenced tests) to invoke the helper or the real transformer code path instead
of calling unwrap_or directly so the tests fail if the production merge/error
logic regresses.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eb53e2e2-5ff4-4085-9c8c-b21f86d219b9

📥 Commits

Reviewing files that changed from the base of the PR and between 3776f54 and b50f76b.

📒 Files selected for processing (32)
  • packages/rs-dpp/src/identity/conversion/platform_value/mod.rs
  • packages/rs-dpp/src/identity/identity.rs
  • packages/rs-dpp/src/identity/identity_facade.rs
  • packages/rs-dpp/src/identity/identity_public_key/conversion/json/mod.rs
  • packages/rs-dpp/src/identity/identity_public_key/conversion/platform_value/mod.rs
  • packages/rs-dpp/src/identity/identity_public_key/v0/conversion/json.rs
  • packages/rs-dpp/src/identity/identity_public_key/v0/conversion/platform_value.rs
  • packages/rs-dpp/src/identity/v0/conversion/json.rs
  • packages/rs-dpp/src/identity/v0/conversion/platform_value.rs
  • packages/rs-drive-proof-verifier/src/from_request.rs
  • packages/rs-drive-proof-verifier/src/proof.rs
  • packages/rs-drive-proof-verifier/src/proof/groups.rs
  • packages/rs-drive-proof-verifier/src/proof/identity_token_balance.rs
  • packages/rs-drive-proof-verifier/src/proof/token_contract_info.rs
  • packages/rs-drive-proof-verifier/src/proof/token_info.rs
  • packages/rs-drive-proof-verifier/src/proof/token_perpetual_distribution_last_claim.rs
  • packages/rs-drive-proof-verifier/src/proof/token_pre_programmed_distributions.rs
  • packages/rs-drive-proof-verifier/src/verify.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_config_update_transition_action/v0/mod.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_config_update_transition_action/v0/transformer.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/v0/mod.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_destroy_frozen_funds_transition_action/v0/transformer.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_direct_purchase_transition_action/mod.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_direct_purchase_transition_action/v0/mod.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_emergency_action_transition_action/mod.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/mod.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_set_price_for_direct_purchase_transition_action/mod.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_set_price_for_direct_purchase_transition_action/v0/mod.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_unfreeze_transition_action/mod.rs
  • packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_unfreeze_transition_action/v0/transformer.rs

Comment thread packages/rs-dpp/src/identity/conversion/platform_value/mod.rs Outdated
Comment on lines +5809 to +5845
#[test]
fn broadcast_state_transition_empty_metadata_when_missing() {
// Deserialization of empty state_transition fails first on real data,
// but in our case we want to ensure the proof branch fires correctly
// when metadata is missing.
use platform::wait_for_state_transition_result_response::{
wait_for_state_transition_result_response_v0::Result as V0Result, Version,
WaitForStateTransitionResultResponseV0,
};
// Must use a payload that successfully deserializes - but without
// a valid one, we instead hit ProtocolError. We accept either
// ProtocolError (deserialize fail) or EmptyResponseMetadata
// depending on ordering. Use clearly-invalid payload so decode
// explicitly errors first and assert ProtocolError.
let request = platform::BroadcastStateTransitionRequest {
state_transition: vec![0xFFu8; 4],
};
let response = platform::WaitForStateTransitionResultResponse {
version: Some(Version::V0(WaitForStateTransitionResultResponseV0 {
result: Some(V0Result::Proof(Proof::default())),
metadata: None, // missing
})),
};
let provider = unreachable_provider();
let err = <StateTransitionProofResult as FromProof<
platform::BroadcastStateTransitionRequest,
>>::maybe_from_proof(
request,
response,
Network::Testnet,
default_platform_version(),
&provider,
)
.unwrap_err();
// Order: proof extracted -> state_transition decoded -> metadata
// checked. ProtocolError triggers on the decode.
assert!(matches!(err, Error::ProtocolError { .. }), "got: {err:?}");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Make this test actually cover missing metadata.

This test is named for the missing-metadata path, but the invalid state_transition payload triggers Error::ProtocolError before Line 1437 reads metadata, so it does not exercise EmptyResponseMetadata. Please use a valid serialized state transition fixture here, or rename the test to reflect that invalid payloads fail before metadata validation.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/rs-drive-proof-verifier/src/proof.rs` around lines 5809 - 5845, The
test broadcast_state_transition_empty_metadata_when_missing currently uses an
invalid state_transition (vec![0xFF;4]) which triggers Error::ProtocolError
before metadata is checked; replace that payload with a valid serialized state
transition (e.g. serialize a default/fixture StateTransition using the same
platform codec used in production) so
StateTransitionProofResult::maybe_from_proof proceeds to the metadata check and
the test can assert Error::EmptyResponseMetadata, or alternatively rename the
test to indicate it verifies deserialization failure; update the assertion to
expect Error::EmptyResponseMetadata when using the valid payload.

Comment thread packages/rs-drive-proof-verifier/src/proof/token_contract_info.rs Outdated
Comment thread packages/rs-drive-proof-verifier/src/verify.rs
Comment on lines +423 to +429
#[test]
fn freeze_borrowed_path_dereferences_identity_for_new_action_v0() {
let id = Identifier::new([0xAB; 32]);
// Mirror the `identity_to_freeze_id: *identity_to_freeze_id` pattern.
let copied = *&id;
assert_eq!(copied, id);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Clippy deref_addrof will fail the lint gate.

let copied = *&id; triggers clippy::deref_addrof (needless & then *). Since the workspace enforces clippy-clean builds and macOS CI is already reported failing on this PR, this likely contributes. Also, this test doesn't really exercise the transformer — it's just asserting Copy on Identifier. Consider either removing it or rewriting without the needless addrof:

Proposed fix
-    #[test]
-    fn freeze_borrowed_path_dereferences_identity_for_new_action_v0() {
-        let id = Identifier::new([0xAB; 32]);
-        // Mirror the `identity_to_freeze_id: *identity_to_freeze_id` pattern.
-        let copied = *&id;
-        assert_eq!(copied, id);
-    }
+    #[test]
+    fn freeze_borrowed_path_dereferences_identity_for_new_action_v0() {
+        let id = Identifier::new([0xAB; 32]);
+        // Mirror the `identity_to_freeze_id: *identity_to_freeze_id` pattern
+        // (relies on `Identifier: Copy`).
+        let r = &id;
+        let copied: Identifier = *r;
+        assert_eq!(copied, id);
+    }

As per coding guidelines: "Follow rustfmt defaults and keep code clippy-clean for Rust modules".

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#[test]
fn freeze_borrowed_path_dereferences_identity_for_new_action_v0() {
let id = Identifier::new([0xAB; 32]);
// Mirror the `identity_to_freeze_id: *identity_to_freeze_id` pattern.
let copied = *&id;
assert_eq!(copied, id);
}
#[test]
fn freeze_borrowed_path_dereferences_identity_for_new_action_v0() {
let id = Identifier::new([0xAB; 32]);
// Mirror the `identity_to_freeze_id: *identity_to_freeze_id` pattern
// (relies on `Identifier: Copy`).
let r = &id;
let copied: Identifier = *r;
assert_eq!(copied, id);
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/rs-drive/src/state_transition_action/batch/batched_transition/token_transition/token_freeze_transition_action/v0/transformer.rs`
around lines 423 - 429, The test
freeze_borrowed_path_dereferences_identity_for_new_action_v0 contains a needless
addrof deref pattern `let copied = *&id;` which triggers clippy::deref_addrof;
fix it by replacing that line with a direct copy `let copied = id;` (or remove
the trivial test entirely if it adds no value), referencing the Identifier type
and the test function name so you locate the code path to change.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

❌ Patch coverage is 98.49414% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.00%. Comparing base (3776f54) to head (a50faac).
⚠️ Report is 1 commits behind head on v3.1-dev.

Files with missing lines Patch % Lines
..._config_update_transition_action/v0/transformer.rs 93.80% 7 Missing ⚠️
packages/rs-dpp/src/identity/v0/conversion/json.rs 94.44% 4 Missing ⚠️
...price_for_direct_purchase_transition_action/mod.rs 97.16% 4 Missing ⚠️
...ce_for_direct_purchase_transition_action/v0/mod.rs 96.25% 3 Missing ⚠️
packages/rs-dpp/src/identity/identity_facade.rs 98.63% 2 Missing ⚠️
...s-dpp/src/identity/v0/conversion/platform_value.rs 97.26% 2 Missing ⚠️
...on/token_config_update_transition_action/v0/mod.rs 97.50% 2 Missing ⚠️
...-dpp/src/identity/conversion/platform_value/mod.rs 98.70% 1 Missing ⚠️
...identity/identity_public_key/v0/conversion/json.rs 98.82% 1 Missing ⚠️
...y_frozen_funds_transition_action/v0/transformer.rs 98.64% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           v3.1-dev    #3526      +/-   ##
============================================
+ Coverage     87.84%   88.00%   +0.16%     
============================================
  Files          2474     2474              
  Lines        292800   294440    +1640     
============================================
+ Hits         257196   259132    +1936     
+ Misses        35604    35308     -296     
Components Coverage Δ
dpp 87.79% <98.62%> (+0.52%) ⬆️
drive 87.27% <98.40%> (+0.11%) ⬆️
drive-abci 89.58% <ø> (-0.02%) ⬇️
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 92.26% <ø> (+0.07%) ⬆️
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 03f142b into v3.1-dev Apr 23, 2026
38 checks passed
@QuantumExplorer QuantumExplorer deleted the test/coverage-proof-verifier-batch-actions branch April 23, 2026 11:21
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