Skip to content

test(drive): improve coverage for vote poll query modules#3445

Merged
QuantumExplorer merged 1 commit into
v3.1-devfrom
test/drive-vote-query-coverage
Apr 7, 2026
Merged

test(drive): improve coverage for vote poll query modules#3445
QuantumExplorer merged 1 commit into
v3.1-devfrom
test/drive-vote-query-coverage

Conversation

@QuantumExplorer
Copy link
Copy Markdown
Member

@QuantumExplorer QuantumExplorer commented Apr 7, 2026

Summary

Adds 61 tests across 5 vote/query files in rs-drive, covering path query construction, TryFrom conversions, and result handling.

File New Tests What's covered
vote_poll_vote_state_query.rs 19 TryFrom, has_vote_tally/has_documents, construct_path_query for all result types and start_at variants
vote_polls_by_end_date_query.rs 13 All 9 time-bound combinations, path_query_for_end_time_included/single
contested_resource_votes_given_by_identity_query.rs 8 ascending/descending, start_at variants, offset+limit
vote_poll_contestant_votes_query.rs 7 DPNS fixture, direction/start_at combos
vote_polls_by_document_type_query.rs 14 resolve success/failure, construct_path_query, result_is_in_key, error paths

Test plan

  • cargo test -p drive --lib passes
  • cargo fmt --all clean
  • CI

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added comprehensive unit test coverage for voting and contested resource query functionality, including validation of query construction, path handling, parameter propagation, and error handling across multiple scenarios.

…nversions

Add 61 unit tests across 5 vote query modules covering real logic paths:

- vote_poll_vote_state_query: TryFrom<i32> conversion, FinalizedResult
  conversion edge cases, construct_path_query for all result types
  (Documents, VoteTally, DocumentsAndVoteTally, SingleDocumentByContender),
  offset/limit propagation, start_at included/excluded, conditional
  subqueries for stored info / lock / abstain keys
- vote_polls_by_end_date_query: construct_path_query for all 9 time
  bound combinations, path_query_for_end_time_included, and
  path_query_for_single_end_time
- contested_resource_votes_given_by_identity_query: construct_path_query
  for ascending/descending with all start_at variants, offset/limit,
  identity_id path verification
- vote_poll_contestant_votes_query: construct_path_query for all
  direction/start_at combinations using DPNS contract fixture
- vote_polls_by_document_type_query: resolve_with_provided_borrowed_contract
  success/failure, construct_path_query_with_known_index for all
  start_at/direction combinations, result_is_in_key, result_path_index,
  index name validation, too-many-start-values error

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 7, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 7, 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: 4c10bd98-c5a2-421a-8875-fb35f610033d

📥 Commits

Reviewing files that changed from the base of the PR and between dbc2bdf and 57b1098.

📒 Files selected for processing (5)
  • packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs
  • packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs
  • packages/rs-drive/src/query/vote_poll_vote_state_query.rs
  • packages/rs-drive/src/query/vote_polls_by_document_type_query.rs
  • packages/rs-drive/src/query/vote_polls_by_end_date_query.rs

📝 Walkthrough

Walkthrough

Four files in the query module received comprehensive #[cfg(test)] test modules that validate path query construction, result type predicates, type conversions, and edge cases across contested resource votes, vote poll contestant votes, vote poll vote state, and vote polls by document type and end date queries.

Changes

Cohort / File(s) Summary
Query Path Construction Tests
packages/rs-drive/src/query/contested_resource_votes_given_by_identity_query.rs, packages/rs-drive/src/query/vote_poll_contestant_votes_query.rs, packages/rs-drive/src/query/vote_polls_by_end_date_query.rs
Added test modules validating construct_path_query behavior across start_at None/Some variants, assertion of correct QueryItem types based on ordering, and propagation of limit/offset parameters.
Vote Poll Query Tests
packages/rs-drive/src/query/vote_poll_vote_state_query.rs
Added comprehensive tests for result type predicates (has_vote_tally(), has_documents()), TryFrom conversions with error handling, path query construction with limit adjustments, and subquery configuration validation.
Vote Polls by Document Type Tests
packages/rs-drive/src/query/vote_polls_by_document_type_query.rs
Added tests for contract resolution, path query construction across ascending/descending orders, start_at inclusion/exclusion mapping, subquery presence logic, and helper method validation with error case coverage.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Hops through the test suite with glee,
Checking each query flows just right, you see!
Path constructions and votes all tallied true,
Four files of tests—a comprehensive crew!
Coverage blooms where the rabbits have played, 🌿

🚥 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 'test(drive): improve coverage for vote poll query modules' accurately summarizes the main change—adding comprehensive unit tests across five vote/query related files to improve test coverage.
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/drive-vote-query-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.

@thepastaclaw
Copy link
Copy Markdown
Collaborator

thepastaclaw commented Apr 7, 2026

⏳ Review in progress (commit 57b1098)

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 7, 2026

Codecov Report

❌ Patch coverage is 97.13790% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.26%. Comparing base (dbc2bdf) to head (57b1098).
⚠️ Report is 2 commits behind head on v3.1-dev.

Files with missing lines Patch % Lines
...s/rs-drive/src/query/vote_poll_vote_state_query.rs 97.26% 11 Missing ⚠️
...rs-drive/src/query/vote_polls_by_end_date_query.rs 94.84% 10 Missing ⚠️
...ontested_resource_votes_given_by_identity_query.rs 97.29% 4 Missing ⚠️
...rive/src/query/vote_poll_contestant_votes_query.rs 97.54% 4 Missing ⚠️
...ive/src/query/vote_polls_by_document_type_query.rs 98.37% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           v3.1-dev    #3445      +/-   ##
============================================
+ Coverage     81.17%   81.26%   +0.08%     
============================================
  Files          2852     2852              
  Lines        290349   291502    +1153     
============================================
+ Hits         235700   236891    +1191     
+ Misses        54649    54611      -38     
Components Coverage Δ
dpp 74.38% <ø> (+<0.01%) ⬆️
drive 83.28% <97.13%> (+0.21%) ⬆️
drive-abci 86.70% <ø> (ø)
sdk 36.55% <ø> (ø)
dapi-client 79.06% <ø> (ø)
platform-version ∅ <ø> (∅)
platform-value 92.00% <ø> (ø)
platform-wallet 76.09% <ø> (ø)
drive-proof-verifier 55.26% <ø> (ø)
🚀 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 0c72404 into v3.1-dev Apr 7, 2026
41 checks passed
@QuantumExplorer QuantumExplorer deleted the test/drive-vote-query-coverage branch April 7, 2026 21:19
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