Skip to content

test(drive-abci): add comprehensive tests for group query modules#3268

Merged
QuantumExplorer merged 2 commits into
v3.1-devfrom
test/drive-abci-group-queries-tests
Mar 15, 2026
Merged

test(drive-abci): add comprehensive tests for group query modules#3268
QuantumExplorer merged 2 commits into
v3.1-devfrom
test/drive-abci-group-queries-tests

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Mar 14, 2026

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

The 4 group query modules in packages/rs-drive-abci/src/query/group_queries/ had 0% test coverage. This PR adds comprehensive unit tests to achieve >93% coverage.

What was done?

Added 59 unit tests across all 4 group query v0 modules:

  • group_info/v0 (9 tests): validation errors (invalid contract ID, empty ID, position overflow), prove/no-prove paths with empty state, boundary test at u16::MAX, and populated group data with member entries
  • group_infos/v0 (11 tests): validation errors, limit errors (zero, exceeds max), start position boundaries (valid, overflow, included/not-included), prove/no-prove paths, and populated groups with prove
  • group_actions/v0 (25 tests): all validation paths (contract ID, position, limit, start action ID, status) plus populated data tests for every token event type: Mint, Burn, Freeze, Unfreeze, DestroyFrozenFunds, EmergencyAction (Pause/Resume), ConfigUpdate, ChangePriceForDirectPurchase (None/SinglePrice/SetPrices)
  • group_action_signers/v0 (14 tests): validation errors (contract ID, action ID, position, status), prove/no-prove paths, closed status, boundary tests, and populated action with verified signer data

Tests follow existing patterns from other query modules (data_contract, balance, prefunded_specialized_balances).

How Has This Been Tested?

cargo test --package drive-abci -- query::group_queries
# Result: 59 passed; 0 failed

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

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Expanded test coverage across all group query paths (group info(s), actions, and action signers)
    • Added validations for IDs, limits, start positions, and boundary position (u16::MAX)
    • Verified prove vs non-prove responses, empty vs populated state, and token-event payload handling
    • End-to-end signer and membership scenarios included
    • No changes to public APIs or runtime behavior

Add 59 unit tests across all 4 group query v0 modules to achieve >93%
code coverage:

- group_info/v0: 9 tests covering validation errors, prove/no-prove
  paths, empty state, and populated group data with member entries
- group_infos/v0: 11 tests covering validation, limit errors, start
  position boundaries, prove/no-prove, and populated groups prove
- group_actions/v0: 25 tests covering all validation paths plus
  populated data tests for every token event type (Mint, Burn, Freeze,
  Unfreeze, DestroyFrozenFunds, EmergencyAction Pause/Resume,
  ConfigUpdate, ChangePriceForDirectPurchase with None/Single/Variable)
- group_action_signers/v0: 14 tests covering validation, boundaries,
  prove/no-prove, and populated action with verified signer data

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

coderabbitai Bot commented Mar 14, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 298b9eb2-15a3-444f-8067-ff9390c2fbe7

📥 Commits

Reviewing files that changed from the base of the PR and between 3f1ecac and 78db252.

📒 Files selected for processing (2)
  • packages/rs-drive-abci/src/query/group_queries/group_actions/v0/mod.rs
  • packages/rs-drive-abci/src/query/group_queries/group_infos/v0/mod.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/rs-drive-abci/src/query/group_queries/group_infos/v0/mod.rs
  • packages/rs-drive-abci/src/query/group_queries/group_actions/v0/mod.rs

📝 Walkthrough

Walkthrough

Adds comprehensive test suites to four group query modules exercising validation, boundary conditions, empty-state and prove paths, and integration scenarios for group info, group infos, group actions, and group action signers. No production code or public API signatures were modified.

Changes

Cohort / File(s) Summary
Group query test suites
packages/rs-drive-abci/src/query/group_queries/group_action_signers/v0/mod.rs, packages/rs-drive-abci/src/query/group_queries/group_actions/v0/mod.rs, packages/rs-drive-abci/src/query/group_queries/group_info/v0/mod.rs, packages/rs-drive-abci/src/query/group_queries/group_infos/v0/mod.rs
Adds extensive #[cfg(test)] modules with unit and integration tests covering: contract_id/action_id validation, group_contract_position and limit boundaries (including u16::MAX), status validation, empty-state behavior, prove vs non-prove responses, end-to-end setups inserting groups/actions/signers, and proof payload verification. No production logic or public signatures changed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 New tests hop in, tidy and bright,
Edges checked by moon and by light,
Groups and actions align in a row,
Proofs and signers put on a show,
A cheerful rabbit applauds the night.

🚥 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 and clearly summarizes the main change: adding comprehensive test suites across four group query modules (group_info, group_infos, group_actions, group_action_signers) with 59 new tests and coverage improvements from 0% to >93%.
Docstring Coverage ✅ Passed Docstring coverage is 93.75% 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 (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test/drive-abci-group-queries-tests
📝 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 (6)
packages/rs-drive-abci/src/query/group_queries/group_infos/v0/mod.rs (2)

355-403: Add one populated non-prove assertion for returned group payload.

This test verifies only the proof branch. Add a non-prove populated test that checks group_contract_position, members, and group_required_power so serialization/mapping regressions are caught in this module too.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/rs-drive-abci/src/query/group_queries/group_infos/v0/mod.rs` around
lines 355 - 403, Add a new test (or extend the existing
test_query_group_infos_with_populated_groups_prove) that sends a
GetGroupInfosRequestV0 with prove: false and the same populated groups, then
call platform.query_group_infos_v0(request, &state, version) and assert
result.errors.is_empty() and that result.data contains GetGroupInfosResponseV0
with a Result::GroupInfos (non-proof) payload; inside that payload verify the
group's group_contract_position equals 0 (or the inserted key),
group_required_power equals 5, and the members map contains the member
Identifier ([2u8;32]) with power 5 to catch serialization/mapping regressions.

182-211: Tighten invalid-limit tests to assert the exact failure shape.

Line 194 and Line 210 currently assert only is_err(), which can pass on unrelated failures. Please match the specific InvalidLimit path to make these tests deterministic and intention-revealing.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/rs-drive-abci/src/query/group_queries/group_infos/v0/mod.rs` around
lines 182 - 211, Update the two tests (test_invalid_limit_zero and
test_invalid_limit_exceeds_max) to assert the specific InvalidLimit failure
instead of only is_err(): call platform.query_group_infos_v0(...), take the Err
via unwrap_err() or match on the result, and assert that the error matches the
InvalidLimit variant/path (the exact Query/Validation error produced by
query_group_infos_v0 for bad count). Keep references to the same request type
GetGroupInfosRequestV0 and function query_group_infos_v0 so the assertion
targets the specific InvalidLimit variant rather than any error.
packages/rs-drive-abci/src/query/group_queries/group_info/v0/mod.rs (1)

253-358: Consider extracting shared populated-group setup into a helper.

The arrangement logic is repeated in both populated tests; a small helper would reduce maintenance overhead and keep intent-focused assertions shorter.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/rs-drive-abci/src/query/group_queries/group_info/v0/mod.rs` around
lines 253 - 358, Both tests test_query_group_info_with_populated_group and
test_query_group_info_with_populated_group_prove duplicate the same
populated-group setup; extract that into a small helper (e.g., fn
create_populated_group(platform: &PlatformType, state: &StateType, version:
&VersionType) -> (Identifier, Identifier) or a helper that returns (contract_id,
member_id, state, version) ) that performs the Identifier::from(...) creation,
builds the BTreeMap members, constructs Group::V0(GroupV0 { ... }), inserts it
into platform.drive.add_new_groups(...), and returns the contract_id and
member_id (or the full request). Replace the duplicated setup in both tests with
calls to this helper and only keep the test-specific request/assert logic
(GetGroupInfoRequestV0 creation and assertions).
packages/rs-drive-abci/src/query/group_queries/group_actions/v0/mod.rs (2)

638-1164: Consider consolidating repeated request/response scaffolding in event tests.

A tiny helper for “query + unwrap GroupActions” would remove repeated boilerplate and make each test focus only on event-specific assertions.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/rs-drive-abci/src/query/group_queries/group_actions/v0/mod.rs`
around lines 638 - 1164, Add a small test helper that runs
GetGroupActionsRequestV0 against query_group_actions_v0 and returns the
unwrapped GroupActions (or its group_actions Vec) so tests only assert event
specifics; locate usage around setup_group_and_add_action, Query method
query_group_actions_v0, request type GetGroupActionsRequestV0, response type
GetGroupActionsResponseV0 and GroupActions and implement a function (e.g.,
fetch_group_actions_or_panic) that builds the request (contract_id,
group_contract_position:0, status:0, start_at_action_id:None, count:None,
prove:bool), calls platform.query_group_actions_v0(...), ensures no errors and
that result contains
get_group_actions_response_v0::Result::GroupActions(GroupActions { group_actions
}), and returns the group_actions for tests to use, then replace the repeated
scaffolding in each test with calls to this helper.

920-1078: Strengthen a few event tests with explicit event-type assertions.

Line 948, Line 1032, and Line 1074 currently only assert result length. Add event-type checks (as done in neighboring tests) so mapping regressions are caught.

Proposed assertion strengthening
@@
-                assert_eq!(group_actions.len(), 1);
+                assert_eq!(group_actions.len(), 1);
+                let event = group_actions[0]
+                    .event
+                    .as_ref()
+                    .expect("expected event")
+                    .event_type
+                    .as_ref();
+                assert!(matches!(
+                    event,
+                    Some(group_action_event::EventType::TokenEvent(t))
+                        if matches!(t.r#type.as_ref(), Some(token_event::Type::EmergencyAction(_)))
+                ));
@@
-                assert_eq!(group_actions.len(), 1);
+                assert_eq!(group_actions.len(), 1);
+                let event = group_actions[0]
+                    .event
+                    .as_ref()
+                    .expect("expected event")
+                    .event_type
+                    .as_ref();
+                assert!(matches!(
+                    event,
+                    Some(group_action_event::EventType::TokenEvent(t))
+                        if matches!(t.r#type.as_ref(), Some(token_event::Type::UpdatePrice(_)))
+                ));
@@
-                assert_eq!(group_actions.len(), 1);
+                assert_eq!(group_actions.len(), 1);
+                let event = group_actions[0]
+                    .event
+                    .as_ref()
+                    .expect("expected event")
+                    .event_type
+                    .as_ref();
+                assert!(matches!(
+                    event,
+                    Some(group_action_event::EventType::TokenEvent(t))
+                        if matches!(t.r#type.as_ref(), Some(token_event::Type::UpdatePrice(_)))
+                ));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/rs-drive-abci/src/query/group_queries/group_actions/v0/mod.rs`
around lines 920 - 1078, For each of the three tests
(test_query_group_actions_with_emergency_action_resume,
test_query_group_actions_with_change_price_single_price,
test_query_group_actions_with_change_price_variable_prices) add an explicit
assertion that the returned group_actions[0].event.event_type is the expected
variant (like the existing check in
test_query_group_actions_with_change_price_no_schedule). Specifically: in
test_query_group_actions_with_emergency_action_resume assert the event is
Some(group_action_event::EventType::TokenEvent(t)) and that t.r#type is
EmergencyAction with TokenEmergencyAction::Resume; in
test_query_group_actions_with_change_price_single_price assert t.r#type is
UpdatePrice with TokenPricingSchedule::SinglePrice(42) (or matching
SinglePrice); and in test_query_group_actions_with_change_price_variable_prices
assert t.r#type is UpdatePrice with TokenPricingSchedule::SetPrices (matching
the inserted map). Use the same pattern of unwrapping event and using matches!()
as in GetGroupActionsResponseV0 / group_action_event::EventType checks to keep
tests consistent.
packages/rs-drive-abci/src/query/group_queries/group_action_signers/v0/mod.rs (1)

386-556: Optional: factor duplicated populated-action setup into a local helper.

Both populated tests repeat the same group/action arrangement; extracting it will keep future signer test additions cheaper and less error-prone.

🤖 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-drive-abci/src/query/group_queries/group_actions/v0/mod.rs`:
- Around line 638-1164: Add a small test helper that runs
GetGroupActionsRequestV0 against query_group_actions_v0 and returns the
unwrapped GroupActions (or its group_actions Vec) so tests only assert event
specifics; locate usage around setup_group_and_add_action, Query method
query_group_actions_v0, request type GetGroupActionsRequestV0, response type
GetGroupActionsResponseV0 and GroupActions and implement a function (e.g.,
fetch_group_actions_or_panic) that builds the request (contract_id,
group_contract_position:0, status:0, start_at_action_id:None, count:None,
prove:bool), calls platform.query_group_actions_v0(...), ensures no errors and
that result contains
get_group_actions_response_v0::Result::GroupActions(GroupActions { group_actions
}), and returns the group_actions for tests to use, then replace the repeated
scaffolding in each test with calls to this helper.
- Around line 920-1078: For each of the three tests
(test_query_group_actions_with_emergency_action_resume,
test_query_group_actions_with_change_price_single_price,
test_query_group_actions_with_change_price_variable_prices) add an explicit
assertion that the returned group_actions[0].event.event_type is the expected
variant (like the existing check in
test_query_group_actions_with_change_price_no_schedule). Specifically: in
test_query_group_actions_with_emergency_action_resume assert the event is
Some(group_action_event::EventType::TokenEvent(t)) and that t.r#type is
EmergencyAction with TokenEmergencyAction::Resume; in
test_query_group_actions_with_change_price_single_price assert t.r#type is
UpdatePrice with TokenPricingSchedule::SinglePrice(42) (or matching
SinglePrice); and in test_query_group_actions_with_change_price_variable_prices
assert t.r#type is UpdatePrice with TokenPricingSchedule::SetPrices (matching
the inserted map). Use the same pattern of unwrapping event and using matches!()
as in GetGroupActionsResponseV0 / group_action_event::EventType checks to keep
tests consistent.

In `@packages/rs-drive-abci/src/query/group_queries/group_info/v0/mod.rs`:
- Around line 253-358: Both tests test_query_group_info_with_populated_group and
test_query_group_info_with_populated_group_prove duplicate the same
populated-group setup; extract that into a small helper (e.g., fn
create_populated_group(platform: &PlatformType, state: &StateType, version:
&VersionType) -> (Identifier, Identifier) or a helper that returns (contract_id,
member_id, state, version) ) that performs the Identifier::from(...) creation,
builds the BTreeMap members, constructs Group::V0(GroupV0 { ... }), inserts it
into platform.drive.add_new_groups(...), and returns the contract_id and
member_id (or the full request). Replace the duplicated setup in both tests with
calls to this helper and only keep the test-specific request/assert logic
(GetGroupInfoRequestV0 creation and assertions).

In `@packages/rs-drive-abci/src/query/group_queries/group_infos/v0/mod.rs`:
- Around line 355-403: Add a new test (or extend the existing
test_query_group_infos_with_populated_groups_prove) that sends a
GetGroupInfosRequestV0 with prove: false and the same populated groups, then
call platform.query_group_infos_v0(request, &state, version) and assert
result.errors.is_empty() and that result.data contains GetGroupInfosResponseV0
with a Result::GroupInfos (non-proof) payload; inside that payload verify the
group's group_contract_position equals 0 (or the inserted key),
group_required_power equals 5, and the members map contains the member
Identifier ([2u8;32]) with power 5 to catch serialization/mapping regressions.
- Around line 182-211: Update the two tests (test_invalid_limit_zero and
test_invalid_limit_exceeds_max) to assert the specific InvalidLimit failure
instead of only is_err(): call platform.query_group_infos_v0(...), take the Err
via unwrap_err() or match on the result, and assert that the error matches the
InvalidLimit variant/path (the exact Query/Validation error produced by
query_group_infos_v0 for bad count). Keep references to the same request type
GetGroupInfosRequestV0 and function query_group_infos_v0 so the assertion
targets the specific InvalidLimit variant rather than any error.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b7e9616c-7d79-492c-bc34-bfea8a709962

📥 Commits

Reviewing files that changed from the base of the PR and between ea02a14 and 3f1ecac.

📒 Files selected for processing (4)
  • packages/rs-drive-abci/src/query/group_queries/group_action_signers/v0/mod.rs
  • packages/rs-drive-abci/src/query/group_queries/group_actions/v0/mod.rs
  • packages/rs-drive-abci/src/query/group_queries/group_info/v0/mod.rs
  • packages/rs-drive-abci/src/query/group_queries/group_infos/v0/mod.rs

@codecov

codecov Bot commented Mar 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.33460% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.49%. Comparing base (ea02a14) to head (78db252).
⚠️ Report is 3 commits behind head on v3.1-dev.

Files with missing lines Patch % Lines
...ci/src/query/group_queries/group_actions/v0/mod.rs 97.59% 16 Missing ⚠️
...abci/src/query/group_queries/group_infos/v0/mod.rs 97.98% 4 Missing ⚠️
...query/group_queries/group_action_signers/v0/mod.rs 99.66% 1 Missing ⚠️
...-abci/src/query/group_queries/group_info/v0/mod.rs 99.38% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           v3.1-dev    #3268      +/-   ##
============================================
- Coverage     68.30%   66.49%   -1.82%     
============================================
  Files          3292     3292              
  Lines        253958   255279    +1321     
============================================
- Hits         173470   169744    -3726     
- Misses        80488    85535    +5047     
Components Coverage Δ
dpp 56.39% <ø> (-1.82%) ⬇️
drive 73.77% <ø> (-3.26%) ⬇️
drive-abci 77.54% <98.33%> (-0.65%) ⬇️
sdk 30.34% <ø> (-0.91%) ⬇️
dapi-client 39.08% <ø> (ø)
platform-version ∅ <ø> (∅)
platform-value 39.35% <ø> (ø)
platform-wallet 60.40% <ø> (ø)
drive-proof-verifier ∅ <ø> (∅)
🚀 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

Copy link
Copy Markdown
Member Author

Duplicate of #3267 which has more tests (44 vs 41) and addressed CodeRabbit feedback.

Address CodeRabbit review feedback:
- Add explicit event-type assertions for emergency_action_resume,
  change_price_single_price, and change_price_variable_prices tests
  instead of only checking result length
- Tighten invalid-limit tests to match the specific InvalidLimit error
  variant rather than a generic is_err() check

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@QuantumExplorer

Copy link
Copy Markdown
Member Author

Reopening - this PR has 59 tests (including all token event type coverage and CodeRabbit feedback addressed) vs 44 in #3267. The latest push also addresses CodeRabbit review feedback by strengthening assertions and using specific error type matching.

@QuantumExplorer QuantumExplorer merged commit e7d4fef into v3.1-dev Mar 15, 2026
25 checks passed
@QuantumExplorer QuantumExplorer deleted the test/drive-abci-group-queries-tests branch March 15, 2026 04:06
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