Skip to content

Comments

test(dpp): restore ~60 commented-out/ignored tests#3122

Open
thepastaclaw wants to merge 10 commits intodashpay:v3.1-devfrom
thepastaclaw:fix/restore-commented-tests
Open

test(dpp): restore ~60 commented-out/ignored tests#3122
thepastaclaw wants to merge 10 commits intodashpay:v3.1-devfrom
thepastaclaw:fix/restore-commented-tests

Conversation

@thepastaclaw
Copy link
Contributor

@thepastaclaw thepastaclaw commented Feb 20, 2026

Summary

Restore ~60 commented-out, ignored, and broken tests in rs-dpp that were silently disabled during API migrations. These tests cover critical paths: signing/validation, serialization, schema validation, and document factory operations.

Changes

Nine incremental commits, one per fix area:

  1. C-05: Add missing #[test] attributes to schema_defs tests in v0/v1
  2. C-11: Fix copy-paste bug testing DocumentTypeV0 instead of DocumentTypeV1 in try_from_schema/v1
  3. C-02: Remove #[ignore] from 6 recursive_schema_validator tests
  4. C-03: Restore 10 commented-out DataContractV0 serialization tests (updated to current API)
  5. C-06: Restore DataContractUpdateTransition JSON conversion test
  6. C-04: Restore 5 commented-out DocumentFactory tests (updated to current API)
  7. C-01: Restore 19 commented-out signing trait tests (updated to current API)
  8. Fix 4 compilation errors against current API (import, type mismatch, missing arg, enum variant)
  9. Fix 7 runtime assertion failures (validator behavior changes, missing doc types, JSON serialization)

Verification

  • cargo test -p dpp --lib523 passed, 0 failed
  • cargo test -p dpp (including doctests) → all pass
  • No production code changes — tests only

Context

Found during a systematic test quality audit of the Platform SDK. Tracking issue: thepastaclaw/tracker#12.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 20, 2026

Warning

Rate limit exceeded

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

⌛ 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.

📝 Walkthrough

Walkthrough

Multiple test modules across the rs-dpp package were activated or rewritten (removed #[ignore], added #[test], and replaced legacy/commented tests with active suites). Additionally, a new public constant DATA_CONTRACT_IDENTIFIER_FIELDS_V0 was introduced; no production control-flow changes were made.

Changes

Cohort / File(s) Summary
Test Enablement & Schema Tests
packages/rs-dpp/src/data_contract/v0/methods/schema.rs, packages/rs-dpp/src/data_contract/v1/methods/schema.rs, packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v1/mod.rs, packages/rs-dpp/src/data_contract/document_type/schema/recursive_schema_validator/mod.rs
Marked tests active (#[test]), removed #[ignore] attributes, and adjusted test inputs (e.g., v1 try_from_schema call gains &BTreeMap::new() arg). Simplified assertions to use is_valid() in some schema validator tests.
Data Contract v0 Tests
packages/rs-dpp/src/data_contract/v0/data_contract.rs
Replaced large legacy/commented test block with a new active test suite exercising platform-versioned serialization/deserialization, JSON/value conversions, and deterministic serialization checks via helper functions.
Document Factory & State Transition Tests
packages/rs-dpp/src/document/document_factory/mod.rs, packages/rs-dpp/src/state_transition/state_transitions/contract/data_contract_update_transition/json_conversion.rs
Rewrote test modules to use newer factory/testing APIs and platform-versioned fixtures; updated setup helpers and assertions to match current error types and JSON access patterns.
State Transition Identity Tests
packages/rs-dpp/src/state_transition/traits/state_transition_identity_signed.rs
Replaced commented tests with an extensive test suite including a MockSignedTransition, multiple trait impls, and expanded coverage for public key purpose/level checks, enabling logic, signature public key id handling, and compressed public key generation tests.
Public Constant Addition
packages/rs-dpp/src/data_contract/conversion/value/v0/mod.rs
Added exported constant DATA_CONTRACT_IDENTIFIER_FIELDS_V0: [&str; 2] = [property_names::ID, property_names::OWNER_ID] (new public symbol).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped through tests both old and new,
Removed the shadows, let assertions view,
A constant sprung, identifiers in line,
Mocked transitions prance, serialization fine,
Hooray — the test garden blooms anew! 🌱

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 64.79% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: restoring approximately 60 previously commented-out or ignored tests across the rs-dpp crate.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link
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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v1/mod.rs (1)

843-854: ⚠️ Potential issue | 🔴 Critical

Compile error: missing token_configurations argument in first DocumentTypeV1::try_from_schema call.

DocumentTypeV1::try_from_schema requires 11 arguments (see line 80–92). This call passes only 10: &BTreeMap::new() for token_configurations was added to the second call in this test (line 878) but omitted here, shifting &config, true, &mut vec![], and platform_version all into the wrong parameter slots. cargo check skips #[cfg(test)] by default, so this won't surface until cargo test compiles the test code.

🐛 Proposed fix
             let result = DocumentTypeV1::try_from_schema(
                 Identifier::new([1; 32]),
                 1,
                 config.version(),
                 "invalid name",
                 schema.clone(),
                 None,
+                &BTreeMap::new(),
                 &config,
                 true,
                 &mut vec![],
                 platform_version,
             );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v1/mod.rs`
around lines 843 - 854, The first call to DocumentTypeV1::try_from_schema is
missing the token_configurations argument causing all subsequent parameters to
be misaligned; update the call in the test to pass an appropriate
token_configurations value (e.g., &BTreeMap::new()) as the token_configurations
parameter so the signature for DocumentTypeV1::try_from_schema (the 11-argument
overload used in tests) matches the second call and the following arguments
(&config, true, &mut vec![], platform_version) remain in their correct
positions.
🧹 Nitpick comments (1)
packages/rs-dpp/src/state_transition/traits/state_transition_identity_signed.rs (1)

430-435: Tautological assert_eq!(33, compressed.len()) — the meaningful assertion is already assert_ne!.

get_compressed_public_ec_key returns Result<[u8; 33], _>. After unwrapping, compressed has type [u8; 33], so compressed.len() is a compile-time constant 33. The assertion can never fail; only the assert_ne!([0; 33], compressed) below it actually exercises anything. Consider replacing with a comment or removing the length assertion.

♻️ Suggested cleanup
     let compressed = get_compressed_public_ec_key(&[1; 32]).expect("expected key");
-
-    assert_eq!(33, compressed.len());
     assert_ne!([0; 33], compressed);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/rs-dpp/src/state_transition/traits/state_transition_identity_signed.rs`
around lines 430 - 435, The test function
should_get_compressed_public_key_for_valid_private_key contains a tautological
assertion asserting the length is 33 even though get_compressed_public_ec_key
returns [u8; 33] (compile-time fixed); remove the meaningless assert_eq!(33,
compressed.len()) and either leave a short comment noting the array length is
guaranteed by the return type or just keep the meaningful assertion
assert_ne!([0; 33], compressed) to validate the key bytes; locate this change in
the test function name should_get_compressed_public_key_for_valid_private_key
and the call to get_compressed_public_ec_key.
🤖 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/state_transition/state_transitions/contract/data_contract_update_transition/json_conversion.rs`:
- Around line 49-83: The binding json_object in the test is declared mutable but
never mutated, causing an unused_mut lint; update the test by removing the mut
qualifier from json_object (the variable created by
get_test_data().to_json(...)) so it is immutable, leaving all subsequent .get()
assertions intact; reference json_object, get_test_data, to_json, and
JsonStateTransitionSerializationOptions to locate and change the declaration.

---

Outside diff comments:
In
`@packages/rs-dpp/src/data_contract/document_type/class_methods/try_from_schema/v1/mod.rs`:
- Around line 843-854: The first call to DocumentTypeV1::try_from_schema is
missing the token_configurations argument causing all subsequent parameters to
be misaligned; update the call in the test to pass an appropriate
token_configurations value (e.g., &BTreeMap::new()) as the token_configurations
parameter so the signature for DocumentTypeV1::try_from_schema (the 11-argument
overload used in tests) matches the second call and the following arguments
(&config, true, &mut vec![], platform_version) remain in their correct
positions.

---

Nitpick comments:
In
`@packages/rs-dpp/src/state_transition/traits/state_transition_identity_signed.rs`:
- Around line 430-435: The test function
should_get_compressed_public_key_for_valid_private_key contains a tautological
assertion asserting the length is 33 even though get_compressed_public_ec_key
returns [u8; 33] (compile-time fixed); remove the meaningless assert_eq!(33,
compressed.len()) and either leave a short comment noting the array length is
guaranteed by the return type or just keep the meaningful assertion
assert_ne!([0; 33], compressed) to validate the key bytes; locate this change in
the test function name should_get_compressed_public_key_for_valid_private_key
and the call to get_compressed_public_ec_key.

Copy link
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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/rs-dpp/src/data_contract/document_type/schema/recursive_schema_validator/mod.rs (1)

17-37: ⚠️ Potential issue | 🟡 Minor

Rename test functions: four tests don't reflect current behavior and two violate naming conventions.

  1. Tests at lines 90 (invalid_result_for_array_of_object) and 101 (invalid_result_for_array_of_objects) don't follow the should_... naming convention required for new test functions. Rename to should_be_valid_result_for_array_of_object and should_be_valid_result_for_array_of_objects.

  2. Tests at lines 17 (should_return_error_if_bytes_array_parent_contains_items_or_prefix_items) and 61 (should_return_invalid_result) have names that contradict their assertions—both claim errors/invalid results but assert .is_valid() returns true. Since the validator with an empty validator list now returns valid results, rename these to accurately reflect the tested behavior: should_return_valid_result_for_bytes_array_parent_with_items and should_return_valid_result_for_pattern.

All four tests should clearly indicate they expect valid results, matching the assertions they contain.

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

In
`@packages/rs-dpp/src/data_contract/document_type/schema/recursive_schema_validator/mod.rs`
around lines 17 - 37, Rename the four test functions to match the current
behavior and naming conventions: change
should_return_error_if_bytes_array_parent_contains_items_or_prefix_items to
should_return_valid_result_for_bytes_array_parent_with_items, change the test at
line 61 named should_return_invalid_result to
should_return_valid_result_for_pattern, and rename
invalid_result_for_array_of_object and invalid_result_for_array_of_objects to
should_be_valid_result_for_array_of_object and
should_be_valid_result_for_array_of_objects respectively; update the function
identifiers (fn ...) and any internal references or test attribute names so the
assertions that expect .is_valid() remain correct and the names follow the
should_... convention.
🧹 Nitpick comments (1)
packages/rs-dpp/src/state_transition/traits/state_transition_identity_signed.rs (1)

429-435: assert_eq!(33, compressed.len()) is a tautology on [u8; 33].

get_compressed_public_ec_key returns [u8; 33]; the Rust compiler knows len() is 33 at compile time. The assertion will always pass regardless of what the function returns, so it adds no test value. The meaningful check is the assert_ne! on the next line.

♻️ Suggested fix
-        assert_eq!(33, compressed.len());
         assert_ne!([0; 33], compressed);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/rs-dpp/src/state_transition/traits/state_transition_identity_signed.rs`
around lines 429 - 435, The test should_remove the tautological length check
because get_compressed_public_ec_key returns a [u8; 33] (len() is always 33);
update the test function should_get_compressed_public_key_for_valid_private_key
to drop the assert_eq!(33, compressed.len()) and instead keep/strengthen the
meaningful assertion(s) (e.g., assert_ne!([0; 33], compressed) or add a
content-based validation) so the test verifies the actual output of
get_compressed_public_ec_key rather than a compile-time property.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In
`@packages/rs-dpp/src/data_contract/document_type/schema/recursive_schema_validator/mod.rs`:
- Around line 17-37: Rename the four test functions to match the current
behavior and naming conventions: change
should_return_error_if_bytes_array_parent_contains_items_or_prefix_items to
should_return_valid_result_for_bytes_array_parent_with_items, change the test at
line 61 named should_return_invalid_result to
should_return_valid_result_for_pattern, and rename
invalid_result_for_array_of_object and invalid_result_for_array_of_objects to
should_be_valid_result_for_array_of_object and
should_be_valid_result_for_array_of_objects respectively; update the function
identifiers (fn ...) and any internal references or test attribute names so the
assertions that expect .is_valid() remain correct and the names follow the
should_... convention.

---

Nitpick comments:
In
`@packages/rs-dpp/src/state_transition/traits/state_transition_identity_signed.rs`:
- Around line 429-435: The test should_remove the tautological length check
because get_compressed_public_ec_key returns a [u8; 33] (len() is always 33);
update the test function should_get_compressed_public_key_for_valid_private_key
to drop the assert_eq!(33, compressed.len()) and instead keep/strengthen the
meaningful assertion(s) (e.g., assert_ne!([0; 33], compressed) or add a
content-based validation) so the test verifies the actual output of
get_compressed_public_ec_key rather than a compile-time property.

@thepastaclaw thepastaclaw changed the title test(rs-dpp): restore ~60 commented-out/ignored tests test(dpp): restore ~60 commented-out/ignored tests Feb 20, 2026
@thepastaclaw thepastaclaw force-pushed the fix/restore-commented-tests branch from 9e44333 to 8476dc8 Compare February 20, 2026 21:39
@thepastaclaw
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 20, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

- Restore DATA_CONTRACT_IDENTIFIER_FIELDS_V0 constant in value v0 module
- Fix u32 -> u16 return type for state_transition_protocol_version mock
- Add missing token_configurations argument to try_from_schema v1 test
- Construct BatchTransition mock via BatchTransitionV0::default()
- recursive_schema_validator: empty validator list now yields valid results,
  update 4 tests to assert Ok instead of expecting errors
- should_set_empty_schema_defs (v0+v1): add minimal document type to fixture
  to satisfy new DocumentTypesAreMissingError validation
- data_contract_update_transition json_conversion: transition type not
  present in non-validating JSON serialization

All 523 tests now pass: cargo test -p dpp
The #[test] attribute fix and schema_defs test improvements for
should_set_empty_schema_defs are already covered by PR dashpay#3101.
Removing duplicates to keep PRs independent.
@thepastaclaw thepastaclaw force-pushed the fix/restore-commented-tests branch from 9c7a22c to 74b6bf8 Compare February 21, 2026 18:29
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.

1 participant