Skip to content

test(drive): address review comments on identity test coverage#3336

Merged
QuantumExplorer merged 1 commit into
v3.1-devfrom
test/drive-identity-review-fixes-v2
Mar 16, 2026
Merged

test(drive): address review comments on identity test coverage#3336
QuantumExplorer merged 1 commit into
v3.1-devfrom
test/drive-identity-review-fixes-v2

Conversation

@QuantumExplorer
Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Addresses code review comments from PR #3330 (identity test coverage).

What was done?

  1. HIGH: BTreeMap ordering assertion is tautological (fetch/mod.rs) -- Replaced with assertions that verify each identity's actual balance is correct in the returned map.

  2. MEDIUM: Weak nonce assertion (fetch/nonce/mod.rs) -- Changed assert!(nonce > 0) to assert_eq!(nonce, 1) with documentation explaining why the value is exactly 1 after merging nonce 1 from initial state.

  3. MEDIUM: Masternode re-insertion test doesn't verify key re-enablement (insert/add_new_identity/mod.rs) -- Now disables all keys before re-insertion, verifies they are disabled, then verifies they are re-enabled after masternode re-insertion.

  4. MEDIUM: Missing edge case -- combined positive balance + negative credit (fetch/balance/mod.rs) -- Added test that sets both positive balance and negative credit, documenting that fetch_identity_balance_include_debt returns just the positive balance when it is nonzero.

  5. LOW: .unwrap() without context (fetch/mod.rs) -- Replaced with .expect("descriptive message").

  6. LOW: Estimated-mode test asserts hardcoded placeholder (fetch/balance/mod.rs) -- Already documented; the comment explains Some(0) is the expected placeholder in apply=false mode.

  7. LOW: assert!(result.is_err()) without checking error type (fetch/balance/mod.rs) -- Now uses matches!(result, Err(Error::GroveDB(_))) with a descriptive failure message.

  8. LOW: Missing test for partial results (fetch/mod.rs) -- Added test where one identity exists and another does not, verifying fetch_identities_balances returns only the existing one.

  9. NIT: Path tests skip root tree byte verification (mod.rs) -- All path function tests now assert path[0] == RootTree::Identities.

  10. NIT: Incomplete enum conversion coverage (mod.rs) -- All three conversion tests (to_u8, to_u8_array, to_static_u8_array_ref) now cover all 6 IdentityRootStructure variants.

How Has This Been Tested?

cargo fmt --package drive
cargo test --package drive -- drive::identity
# 131 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

Fixes from code review on PR #3330:
- Replace tautological BTreeMap ordering assertion with actual data verification
- Assert exact nonce value (1) instead of just nonzero after merge
- Verify keys are re-enabled after masternode re-insertion (disable first, then re-insert)
- Add edge case test for identity with both positive balance and negative credit
- Replace .unwrap() with .expect() with descriptive messages
- Document that Some(0) is expected placeholder in estimated (apply=false) mode
- Match specific GroveDB error variant instead of generic is_err()
- Add partial results test for fetch_identities_balances (some exist, some don't)
- Assert path[0] == RootTree::Identities in all path function tests
- Test all 6 IdentityRootStructure variants in conversion tests

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

coderabbitai Bot commented Mar 16, 2026

Warning

Rate limit exceeded

@QuantumExplorer has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 25 minutes and 54 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f57df2e5-f76d-4ad4-ab57-053daa94b4e3

📥 Commits

Reviewing files that changed from the base of the PR and between f6d3680 and 77fca0f.

📒 Files selected for processing (5)
  • packages/rs-drive/src/drive/identity/fetch/balance/mod.rs
  • packages/rs-drive/src/drive/identity/fetch/mod.rs
  • packages/rs-drive/src/drive/identity/fetch/nonce/mod.rs
  • packages/rs-drive/src/drive/identity/insert/add_new_identity/mod.rs
  • packages/rs-drive/src/drive/identity/mod.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test/drive-identity-review-fixes-v2
📝 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.

@QuantumExplorer
Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 16, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 16, 2026

Codecov Report

❌ Patch coverage is 92.02454% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.60%. Comparing base (5b95606) to head (77fca0f).
⚠️ Report is 2 commits behind head on v3.1-dev.

Files with missing lines Patch % Lines
packages/rs-drive/src/drive/identity/mod.rs 87.75% 6 Missing ⚠️
.../src/drive/identity/insert/add_new_identity/mod.rs 85.71% 4 Missing ⚠️
...s/rs-drive/src/drive/identity/fetch/balance/mod.rs 95.55% 2 Missing ⚠️
packages/rs-drive/src/drive/identity/fetch/mod.rs 97.50% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           v3.1-dev    #3336      +/-   ##
============================================
+ Coverage     73.48%   73.60%   +0.12%     
============================================
  Files          3295     3295              
  Lines        273133   274156    +1023     
============================================
+ Hits         200703   201793    +1090     
+ Misses        72430    72363      -67     
Components Coverage Δ
dpp 60.41% <ø> (+<0.01%) ⬆️
drive 79.14% <92.02%> (+0.27%) ⬆️
drive-abci 85.76% <ø> (ø)
sdk 31.25% <ø> (ø)
dapi-client 79.06% <ø> (ø)
platform-version ∅ <ø> (∅)
platform-value 58.46% <ø> (ø)
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 QuantumExplorer merged commit b963c8c into v3.1-dev Mar 16, 2026
20 checks passed
@QuantumExplorer QuantumExplorer deleted the test/drive-identity-review-fixes-v2 branch March 16, 2026 04:57
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