Skip to content

test(drive): cover multi-range and paginated compacted balance proofs - #4208

Merged
QuantumExplorer merged 2 commits into
v4.1-devfrom
test/compacted-envelope-multirange
Jul 23, 2026
Merged

test(drive): cover multi-range and paginated compacted balance proofs#4208
QuantumExplorer merged 2 commits into
v4.1-devfrom
test/compacted-envelope-multirange

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Jul 23, 2026

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

The compacted address-balance proof was reworked in #4165 into a two-proof envelope (authenticated descending predecessor + separately verified forward scan, root-bound to each other). That shipped without regression coverage for the exact scenario that sank the earlier chained-single-proof attempt in #3792: two or more compacted ranges sorting at/below the queried height, which is the normal paginated-sync shape — the gRPC handler passes an explicit limit and the SDK pages in a loop. All existing verify tests pass limit: None and set up at most one compacted range below the bound.

What was done?

Test-only. Added three honest-roundtrip regression tests to verify_compacted_address_balance_changes/v0:

  • multiple_ranges_below_query_height_verify — three ranges (1,64) (65,128) (129,192), query from 150: verification must succeed (the case the chained approach could not satisfy) and return only the containing range with its stored changes.
  • containing_range_with_lower_and_higher_ranges — a fourth range (193,256) above the bound: the forward scan starts at the authenticated containing range and continues through later ranges in order, while wholly-lower ranges stay excluded.
  • caller_limit_paginates_across_ranges — three limit: Some(1) pages resuming past the last returned range, ending on an empty page that exercises the non-containing-predecessor fallback key under a limit.

Also ported the store_compacted_entry test helper (direct grovedb insert, bypassing compaction) from the #3792 branch so tests can build exact tree shapes.

How Has This Been Tested?

cargo test -p drive --features fixtures-and-mocks --lib verify_compacted — 10 passed, 0 failed (3 new). cargo clippy -p drive --features fixtures-and-mocks --lib --tests clean; cargo fmt --all applied.

Breaking Changes

None — test-only.

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

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added regression coverage for balance-change queries spanning multiple ranges.
    • Verified correct handling of ranges around a queried height, including predecessor fallback behavior.
    • Added paging coverage to ensure limits truncate results and subsequent pages resume correctly.

The two-proof compacted address-balance envelope shipped without
regression coverage for the scenario that sank the original chained-proof
fix: two or more compacted ranges sorting at/below the queried height,
which is the normal paginated-sync shape (the gRPC handler passes an
explicit limit and the SDK pages in a loop).

Add three honest-roundtrip regression tests to the verifier:

- multiple_ranges_below_query_height_verify: three ranges at/below the
  bound; verification must succeed and surface only the containing range
  with its stored changes.
- containing_range_with_lower_and_higher_ranges: the forward scan starts
  at the authenticated containing range and continues through later
  ranges while wholly-lower ranges stay excluded.
- caller_limit_paginates_across_ranges: three limit-1 pages, resuming
  past the last returned range, ending on an empty fallback-key page.

Also port the store_compacted_entry helper that inserts exact-range
entries directly, bypassing compaction, so tests control tree shape.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ab96ba18-6221-4d22-bb85-5e0f8bac26e6

📥 Commits

Reviewing files that changed from the base of the PR and between 13c394e and 4fd4a94.

📒 Files selected for processing (1)
  • packages/rs-drive/src/verify/address_funds/verify_compacted_address_balance_changes/v0/mod.rs

📝 Walkthrough

Walkthrough

This change adds test-only helpers and regression tests for compacted address-balance verification. The tests cover containing-range selection, forward scanning across ranges, and limited pagination without modifying production verification logic.

Changes

Compacted balance verification tests

Layer / File(s) Summary
Deterministic compacted entry setup
packages/rs-drive/src/verify/address_funds/verify_compacted_address_balance_changes/v0/mod.rs
Adds helpers for directly inserting encoded compacted entries and constructing deterministic single-address balance changes.
Range selection and pagination coverage
packages/rs-drive/src/verify/address_funds/verify_compacted_address_balance_changes/v0/mod.rs
Adds tests for containing-range selection, forward scanning across lower and higher ranges, and limited pagination across successive ranges.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

  • dashpay/platform#4165: Introduces the predecessor and forward verification behavior covered by these regression tests.
✨ 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/compacted-envelope-multirange

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.

@QuantumExplorer QuantumExplorer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

reviewed

@QuantumExplorer
QuantumExplorer merged commit 5c251a4 into v4.1-dev Jul 23, 2026
3 of 6 checks passed
@QuantumExplorer
QuantumExplorer deleted the test/compacted-envelope-multirange branch July 23, 2026 03:22
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.77465% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.51%. Comparing base (0f2d4bb) to head (4fd4a94).
⚠️ Report is 13 commits behind head on v4.1-dev.

Files with missing lines Patch % Lines
...verify_compacted_address_balance_changes/v0/mod.rs 95.77% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           v4.1-dev    #4208    +/-   ##
==========================================
  Coverage     87.51%   87.51%            
==========================================
  Files          2666     2667     +1     
  Lines        336904   337576   +672     
==========================================
+ Hits         294837   295427   +590     
- Misses        42067    42149    +82     
Components Coverage Δ
dpp 88.50% <98.38%> (+0.02%) ⬆️
drive 86.26% <95.81%> (+0.02%) ⬆️
drive-abci 89.51% <4.81%> (-0.07%) ⬇️
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 92.88% <94.67%> (-0.02%) ⬇️
platform-wallet ∅ <ø> (∅)
drive-proof-verifier 49.79% <ø> (ø)
🚀 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.

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