Skip to content

test(platform): improve btreemap extensions test coverage#3380

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

test(platform): improve btreemap extensions test coverage#3380
QuantumExplorer merged 1 commit into
v3.1-devfrom
test/platform-value-btreemap-coverage

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Mar 18, 2026

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Improve test coverage for rs-platform-value btreemap extension modules which had very low coverage:

  • btreemap_removal_extensions.rs: 20.1% coverage (414 uncovered lines)
  • btreemap_path_extensions.rs: 9.2% coverage (347 uncovered lines)

What was done?

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

btreemap_removal_extensions.rs (~130 tests):

  • Tests for both BTreeMap<String, Value> (owned) and BTreeMap<String, &Value> (ref) impls
  • Covers all public methods: remove_string, remove_float, remove_integer, remove_bool, remove_hash256_bytes, remove_bytes, remove_identifier, remove_binary_data, remove_bytes_32, remove_bytes_20, remove_hash256s, remove_identifiers, remove_map_as_btree_map, remove_map_as_btree_map_keep_values_as_platform_value, and remove_tuple
  • Each method tested with: happy path, missing key error, null value handling, and type-specific edge cases
  • Tests tuple operations with wrong length arrays, non-array values, and empty arrays
  • Fixes off-by-one bug in remove_optional_tuple (arr.remove(1) after arr.remove(0) shifted the array)

btreemap_path_extensions.rs (~80 tests):

  • Tests get_at_path, get_optional_at_path with single-level, nested, and deeply nested paths
  • Covers all typed getters: string, str, float, integer, bool, identifier, hash256, bytes, identifier_bytes, binary_bytes
  • Covers all typed removers: string, float, integer, hash256, identifier
  • Tests array and map path accessors: get_inner_value_array_at_path, get_inner_string_array_at_path, get_inner_borrowed_str_value_map_at_path
  • Edge cases: empty paths, missing keys at various nesting levels, null values, wrong types
  • Tests generic impl works for both BTreeMap<String, Value> and BTreeMap<String, &Value>

How Has This Been Tested?

  • cargo fmt -p platform-value -- passes
  • cargo test -p platform-value -- all 248 tests pass
  • cargo clippy -p platform-value -- no warnings in modified files

Breaking Changes

None.

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

Summary by CodeRabbit

  • Bug Fixes
    • Fixed tuple removal logic in map operations to correctly account for index shifts when removing multiple elements sequentially.

Add comprehensive unit tests for btreemap_removal_extensions.rs and
btreemap_path_extensions.rs, which previously had 20.1% and 9.2%
coverage respectively. Tests cover both BTreeMap<String, Value> (owned)
and BTreeMap<String, &Value> (ref) impls across all public methods
including string, float, integer, bool, hash256, bytes, identifier,
binary data, bytes32, bytes20, array, map, and tuple operations. Also
fixes an off-by-one bug in remove_optional_tuple where arr.remove(1)
was called after arr.remove(0) had already shifted the array.

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

Two Rust extension modules for BTreeMap handling receive updates: comprehensive test suites are added for path-based access operations, and tuple removal logic is corrected to properly account for index shifts after element removal, accompanied by extensive removal operation tests.

Changes

Cohort / File(s) Summary
Path Extensions Tests
packages/rs-platform-value/src/btreemap_extensions/btreemap_path_extensions.rs
Adds comprehensive test suite covering construction helpers, nested path access (get/get_optional), type-specific accessors (strings, booleans, integers, floats, arrays, bytes, identifiers), and error cases for missing/empty paths.
Removal Extensions Fixes & Tests
packages/rs-platform-value/src/btreemap_extensions/btreemap_removal_extensions.rs
Corrects tuple removal logic to handle index shifts properly after first element removal; adds extensive test coverage for owned and reference map variants across all supported value types including strings, numbers, hashes, bytes, identifiers, maps, arrays, and nested structures.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Hopping through maps with careful stride,
Fixed the indices, shuffled with pride,
Paths now tested, removals align,
Tuple logic shines, each test is fine!
🌟 Extensions leap forward, robust and bright!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 97.77% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title accurately describes the main change: comprehensive test coverage improvements for btreemap extensions modules with ~210 new tests.

✏️ 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-btreemap-coverage
📝 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.

@codecov

codecov Bot commented Mar 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.24%. Comparing base (2fb112c) to head (4a81606).
⚠️ Report is 16 commits behind head on v3.1-dev.

Additional details and impacted files
@@             Coverage Diff              @@
##           v3.1-dev    #3380      +/-   ##
============================================
+ Coverage     75.87%   76.24%   +0.36%     
============================================
  Files          2912     2914       +2     
  Lines        283860   285358    +1498     
============================================
+ Hits         215375   217557    +2182     
+ Misses        68485    67801     -684     
Components Coverage Δ
dpp 65.74% <ø> (+0.03%) ⬆️
drive 81.66% <ø> (+0.01%) ⬆️
drive-abci 85.98% <ø> (-0.01%) ⬇️
sdk 31.25% <ø> (ø)
dapi-client 79.06% <ø> (ø)
platform-version ∅ <ø> (∅)
platform-value 73.84% <100.00%> (+15.38%) ⬆️
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 changed the title test(platform-value): improve btreemap extensions test coverage test(platform): improve btreemap extensions test coverage Mar 18, 2026
@QuantumExplorer QuantumExplorer merged commit e03c58b into v3.1-dev Mar 18, 2026
41 of 43 checks passed
@QuantumExplorer QuantumExplorer deleted the test/platform-value-btreemap-coverage branch March 18, 2026 17:56
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