Skip to content

test(dpp): improve coverage for document serialization, extended documents, and methods#3454

Merged
QuantumExplorer merged 1 commit into
v3.1-devfrom
test/dpp-document-coverage
Apr 8, 2026
Merged

test(dpp): improve coverage for document serialization, extended documents, and methods#3454
QuantumExplorer merged 1 commit into
v3.1-devfrom
test/dpp-document-coverage

Conversation

@QuantumExplorer
Copy link
Copy Markdown
Member

@QuantumExplorer QuantumExplorer commented Apr 8, 2026

Summary

Adds 76 tests across 7 files in rs-dpp/src/document covering real logic.

File Tests What's covered
extended_document/v0/mod.rs 26 Construction, property access, JSON/value conversion, validation, hash
v0/cbor_conversion.rs 9 CBOR round-trips, version prefix, invalid CBOR rejection
v0/json_conversion.rs 8 JSON conversion, timestamp/identifier fields, round-trips
serialization_traits/platform_value_conversion 5 Value round-trips, map conversion
document_methods/get_raw_for_document_type 11 Raw field extraction for all system fields
document_methods/is_equal_ignoring_timestamps 8 Equality with different timestamps, also_ignore_fields
mod.rs 9 Display, increment_revision, hash determinism

Test plan

  • cargo test -p dpp --lib -- document:: passes
  • cargo fmt --all clean
  • CI

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added comprehensive unit tests for document serialization and deserialization across CBOR, JSON, and platform value formats.
    • Added tests validating document field extraction, equality comparison ignoring timestamps, and property access operations.
    • Expanded test coverage for extended document functionality, document display output, and version-dispatch method behavior.
    • Verified round-trip serialization integrity and error handling for malformed inputs across all document formats.

Add comprehensive unit tests covering real logic in document serialization,
conversion, validation, and comparison across 7 files that previously had
zero or minimal test coverage.

- extended_document/v0: construction, property access, JSON/value conversion,
  serialization round-trip, validation, document_type lookup, set/get paths
- v0/cbor_conversion: CBOR round-trip, from_map field extraction, DocumentForCbor
  conversion, version prefix, error handling for invalid CBOR
- v0/json_conversion: to_json/from_json_value round-trip, all timestamp fields,
  creator_id parsing, to_json_with_identifiers_using_bytes
- platform_value_conversion: Document <-> Value round-trip, to_map_value,
  to_object, into_map_value, from_platform_value with minimal data
- get_raw_for_document_type: system field extraction ($id, $ownerId, $creatorId),
  timestamp encoding, block height encoding, owner_id override, user properties
- is_equal_ignoring_timestamps: equal ignoring time fields, different properties,
  different ids/owners/revisions, also_ignore_fields filtering
- document/mod.rs: Display impl edge cases, increment_revision, version dispatch
  for is_equal_ignoring_time_based_fields, get_raw_for_contract, hash

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added this to the v3.1.0 milestone Apr 8, 2026
@thepastaclaw
Copy link
Copy Markdown
Collaborator

thepastaclaw commented Apr 8, 2026

Review Gate

Commit: 2ab601e8

  • Debounce: 1m ago (need 30m)

  • CI checks: checks still running (1 pending)

  • CodeRabbit review: no comment yet

  • Off-peak hours: off-peak (12:54 AM PT Wednesday)

  • Run review now (check to override)

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1f8b1839-2786-447a-a032-f50e8d6dda79

📥 Commits

Reviewing files that changed from the base of the PR and between f733c4d and 2ab601e.

📒 Files selected for processing (7)
  • packages/rs-dpp/src/document/document_methods/get_raw_for_document_type/v0/mod.rs
  • packages/rs-dpp/src/document/document_methods/is_equal_ignoring_timestamps/v0/mod.rs
  • packages/rs-dpp/src/document/extended_document/v0/mod.rs
  • packages/rs-dpp/src/document/mod.rs
  • packages/rs-dpp/src/document/serialization_traits/platform_value_conversion/mod.rs
  • packages/rs-dpp/src/document/v0/cbor_conversion.rs
  • packages/rs-dpp/src/document/v0/json_conversion.rs

📝 Walkthrough

Walkthrough

These changes add comprehensive test modules across seven document-related files to validate serialization/deserialization, property access, timestamp handling, and field extraction behavior. All changes are confined to new #[cfg(test)] test modules with no modifications to public API signatures or runtime logic.

Changes

Cohort / File(s) Summary
Document Method Tests
packages/rs-dpp/src/document/document_methods/get_raw_for_document_type/v0/mod.rs, packages/rs-dpp/src/document/document_methods/is_equal_ignoring_timestamps/v0/mod.rs
Test coverage for system field extraction (e.g., $id, $ownerId, timestamps) with overrides, and equality comparison ignoring time-based fields across various property configurations.
Extended Document Tests
packages/rs-dpp/src/document/extended_document/v0/mod.rs
Comprehensive tests for ExtendedDocumentV0 initialization, field access, property operations, serialization round-trips (JSON, bytes), hashing, and platform value conversions.
Core Document Tests
packages/rs-dpp/src/document/mod.rs
Tests for Display formatting with various field combinations, version-dispatch methods (increment_revision, is_equal_ignoring_time_based_fields, get_raw_for_contract, hash), and contract-driven document type behavior.
Document Serialization Tests
packages/rs-dpp/src/document/serialization_traits/platform_value_conversion/mod.rs, packages/rs-dpp/src/document/v0/cbor_conversion.rs, packages/rs-dpp/src/document/v0/json_conversion.rs
Validation of round-trip serialization/deserialization for platform values, CBOR format (including version prefix and map structure), and JSON conversion with system field extraction, identifier overrides, and timestamp parsing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Testing hops through document lands,
System fields in helpful hands,
Timestamps tucked with care so true,
Serialization tested through and through!
A garden of asserts, now fully grown, 🌱

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 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 change: adding comprehensive unit tests to improve test coverage for document serialization, extended documents, and document methods across seven files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/dpp-document-coverage

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 8, 2026

Codecov Report

❌ Patch coverage is 96.19883% with 52 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.51%. Comparing base (59f233f) to head (2ab601e).
⚠️ Report is 4 commits behind head on v3.1-dev.

Files with missing lines Patch % Lines
packages/rs-dpp/src/document/v0/cbor_conversion.rs 95.12% 10 Missing ⚠️
packages/rs-dpp/src/document/v0/json_conversion.rs 95.51% 10 Missing ⚠️
...ent_methods/is_equal_ignoring_timestamps/v0/mod.rs 91.08% 9 Missing ⚠️
...es/rs-dpp/src/document/extended_document/v0/mod.rs 97.11% 9 Missing ⚠️
packages/rs-dpp/src/document/mod.rs 96.42% 7 Missing ⚠️
...ialization_traits/platform_value_conversion/mod.rs 95.41% 5 Missing ⚠️
...cument_methods/get_raw_for_document_type/v0/mod.rs 99.09% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           v3.1-dev    #3454      +/-   ##
============================================
+ Coverage     83.13%   83.51%   +0.37%     
============================================
  Files          2621     2621              
  Lines        270434   273537    +3103     
============================================
+ Hits         224833   228452    +3619     
+ Misses        45601    45085     -516     
Components Coverage Δ
dpp 77.22% <96.19%> (+1.11%) ⬆️
drive 84.19% <ø> (+0.13%) ⬆️
drive-abci 87.03% <ø> (+0.28%) ⬆️
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 92.03% <ø> (+0.03%) ⬆️
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 7bc901b into v3.1-dev Apr 8, 2026
18 checks passed
@QuantumExplorer QuantumExplorer deleted the test/dpp-document-coverage branch April 8, 2026 08:00
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