Skip to content

test(platform): improve platform-value coverage for inner_value, system_bytes, and serde#3384

Merged
QuantumExplorer merged 1 commit into
v3.1-devfrom
test/platform-value-coverage-round2
Mar 18, 2026
Merged

test(platform): improve platform-value coverage for inner_value, system_bytes, and serde#3384
QuantumExplorer merged 1 commit into
v3.1-devfrom
test/platform-value-coverage-round2

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Mar 18, 2026

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Improves unit test coverage for rs-platform-value modules that had low coverage:

  • inner_value.rs (65.8% -> improved)
  • system_bytes.rs (32.2% -> improved)
  • value_serialization/de.rs (54.6% -> improved)
  • value_serialization/ser.rs (55.8% -> improved)

What was done?

Added comprehensive #[cfg(test)] mod tests blocks to four files:

inner_value.rs (93 new tests):

  • Map accessor methods: get_str, get_integer, get_bool, get_bytes, get_array, get_hash256, get_identifier, etc.
  • Optional variants: get_optional_* for all types
  • Mutator methods: set_into_value, set_value, insert, insert_at_end
  • Remove methods: remove, remove_many, remove_optional_value, remove_integer, remove_identifier, remove_bytes_32, remove_hash256_bytes, remove_bytes, remove_binary_data, remove_array
  • Map helpers: get_from_map, get_optional_from_map, insert_in_map, push_to_map_string_value
  • Error cases: calling map methods on non-map values

system_bytes.rs (73 new tests):

  • Identifier bytes: into_identifier_bytes/to_identifier_bytes from Bytes, Text (bs58), Array, Identifier, Bytes32
  • Binary bytes: into_binary_bytes/to_binary_bytes from Bytes, Text (b64), Array, Bytes20/32/36, Identifier
  • Hash256: into_hash256/to_hash256 from Bytes32, Identifier, Bytes, Text (bs58), Array, with wrong-length errors
  • Bytes20/32/36: into_bytes_20/to_bytes_20, into_bytes_32/to_bytes_32, into_bytes_36/to_bytes_36 with round-trip b64 encoding
  • Identifier: into_identifier/to_identifier from all source types with error cases

value_serialization/de.rs (56 new tests):

  • Typed deserialization: all integer types, f64, bool, string, char, option, unit, arrays, maps, structs, tuples
  • Type mismatch errors: bool, f64, string, seq, map
  • Round-trip: struct, vec, option, nested struct, hashmap
  • Value-to-Value preservation: all Value variants
  • Bytes handling: Bytes, Bytes20, Bytes32, Bytes36, Identifier through visit_bytes
  • Enum deserialization: unit, newtype, struct, and tuple variants

value_serialization/ser.rs (56 new tests):

  • Primitive serialization: all integer types, f32/f64, bool, char, str, string
  • Unit/None/Some serialization
  • Sequences, tuples, maps, structs (regular, unit, newtype, tuple)
  • Enum variants: unit, newtype, tuple, struct
  • Bytes size dispatch: 20 -> Bytes20, 32 -> Bytes32, 36 -> Bytes36, other -> Bytes
  • Value self-serialization for all variants
  • MapKeySerializer error cases

How Has This Been Tested?

cargo fmt -p platform-value   # formatting verified
cargo test -p platform-value --lib   # 347 tests pass (278 new)

Breaking Changes

None. Only test code was added.

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

Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Expanded test coverage for Value operations, type conversions, and serialization/deserialization pathways across multiple modules to enhance code reliability and validation of existing functionality.

…em_bytes, and serde

Add comprehensive unit tests for four modules with low test coverage:

- inner_value.rs: tests for all map accessor/mutator methods (get_str,
  get_integer, get_bool, get_bytes, get_array, get_hash256,
  get_identifier, etc.) with both correct and wrong type inputs,
  plus insert/remove operations and error cases on non-map values.

- system_bytes.rs: tests for encode/decode round-trips across all
  system byte types (identifier_bytes, binary_bytes, hash256,
  bytes_20, bytes_32, bytes_36, identifier) from multiple Value
  variants (Bytes, Text, Array, Identifier, Bytes32) with error cases.

- value_serialization/de.rs: tests for serde Deserializer covering
  all integer types, floats, bools, strings, chars, options, arrays,
  maps, structs, tuples, enums, unit types, newtype structs, and
  round-trip Rust-to-Value-to-Rust deserialization.

- value_serialization/ser.rs: tests for serde Serializer covering
  all primitive types, sequences, tuples, maps, structs, enums
  (unit/newtype/tuple/struct variants), bytes serialization with
  size-based dispatch, Value self-serialization, and MapKeySerializer
  error cases.

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 Mar 18, 2026
@coderabbitai

coderabbitai Bot commented Mar 18, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Four test modules have been added to the rs-platform-value crate, establishing comprehensive coverage for Value operations, byte conversions, and serde serialization/deserialization. No production code modifications were made.

Changes

Cohort / File(s) Summary
Core Value Operations
packages/rs-platform-value/src/inner_value.rs
Extensive test suite for Value has/get/get_mut operations, set/insert/remove variants, and map-manipulation utilities across scalar, binary, array, and specialized types (integers, strings, bools, hashes, identifiers).
Byte Conversion Tests
packages/rs-platform-value/src/system_bytes.rs
Large suite of unit tests for Value conversions: identifier_bytes, binary_bytes, hash256, bytes_20/32/36 variants with multiple input forms and error cases. Note: introduces two separate test module blocks potentially causing naming conflicts.
Serialization/Deserialization
packages/rs-platform-value/src/value_serialization/ser.rs, packages/rs-platform-value/src/value_serialization/de.rs
Comprehensive serde test coverage for primitive serialization, structs, tuples, maps, enums, byte handling, round-trip conversions, and error cases across both serializer and deserializer implementations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 With whiskers twitching, tests we weave,
Four thousand lines of checks, believe!
From bytes to Values, round we go,
Serde paths mapped with testing glow.
No bugs shall hide, no edge slip by—
A warren of tests beneath the sky! ✨

🚥 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 PR title accurately summarizes the main objective: adding extensive test coverage improvements to multiple rs-platform-value modules (inner_value, system_bytes, and serde serialization/deserialization).
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/platform-value-coverage-round2
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (1)
packages/rs-platform-value/src/system_bytes.rs (1)

1459-1464: Minor: Unnecessary clone.

The arr.clone() on line 1461 is unnecessary since arr is not used after the Value::Array(arr.clone()) call. This is a very minor nit.

Suggested fix
     #[test]
     fn to_identifier_from_array_of_32_u8s() {
         let arr: Vec<Value> = (0..32).map(|i| Value::U8(i as u8)).collect();
-        let val = Value::Array(arr.clone());
+        let val = Value::Array(arr);
         let expected: [u8; 32] = core::array::from_fn(|i| i as u8);
         assert_eq!(val.to_identifier().unwrap(), Identifier::new(expected));
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/rs-platform-value/src/system_bytes.rs` around lines 1459 - 1464, In
the test function to_identifier_from_array_of_32_u8s, remove the unnecessary
arr.clone() when constructing Value::Array since arr isn’t used afterward;
change Value::Array(arr.clone()) to Value::Array(arr) so ownership moves and
avoids an extra clone of arr.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/rs-platform-value/src/system_bytes.rs`:
- Around line 1459-1464: In the test function
to_identifier_from_array_of_32_u8s, remove the unnecessary arr.clone() when
constructing Value::Array since arr isn’t used afterward; change
Value::Array(arr.clone()) to Value::Array(arr) so ownership moves and avoids an
extra clone of arr.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b3c2d531-22ba-4db7-ae17-5a455d45db17

📥 Commits

Reviewing files that changed from the base of the PR and between 94bdedf and ead100d.

📒 Files selected for processing (4)
  • packages/rs-platform-value/src/inner_value.rs
  • packages/rs-platform-value/src/system_bytes.rs
  • packages/rs-platform-value/src/value_serialization/de.rs
  • packages/rs-platform-value/src/value_serialization/ser.rs

@codecov

codecov Bot commented Mar 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.46429% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.84%. Comparing base (2fb112c) to head (ead100d).
⚠️ Report is 19 commits behind head on v3.1-dev.

Files with missing lines Patch % Lines
...es/rs-platform-value/src/value_serialization/de.rs 98.15% 6 Missing ⚠️
...s/rs-platform-value/src/value_serialization/ser.rs 98.90% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           v3.1-dev    #3384      +/-   ##
============================================
+ Coverage     75.87%   76.84%   +0.97%     
============================================
  Files          2912     2914       +2     
  Lines        283860   287933    +4073     
============================================
+ Hits         215375   221260    +5885     
+ Misses        68485    66673    -1812     
Components Coverage Δ
dpp 67.30% <ø> (+1.59%) ⬆️
drive 81.66% <ø> (+0.01%) ⬆️
drive-abci 85.98% <ø> (-0.01%) ⬇️
sdk 31.25% <ø> (ø)
dapi-client 79.06% <ø> (ø)
platform-version ∅ <ø> (∅)
platform-value 83.35% <99.46%> (+24.89%) ⬆️
platform-wallet 60.40% <ø> (ø)
drive-proof-verifier 48.00% <ø> (ø)
🚀 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 ac40dde into v3.1-dev Mar 18, 2026
41 checks passed
@QuantumExplorer QuantumExplorer deleted the test/platform-value-coverage-round2 branch March 18, 2026 19:55
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