Skip to content

test: cover abci handler, drive contract/document/group, drive-abci config#3516

Merged
QuantumExplorer merged 1 commit into
v3.1-devfrom
test/coverage-abci-handler-document-contract-group
Apr 23, 2026
Merged

test: cover abci handler, drive contract/document/group, drive-abci config#3516
QuantumExplorer merged 1 commit into
v3.1-devfrom
test/coverage-abci-handler-document-contract-group

Conversation

@QuantumExplorer
Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Eighth PR in the push toward 90% global coverage. After #3503#3513 we're at 87.04%. This PR targets ~2,800 missed lines across 10 sub-modules, focusing on the lowest-coverage files (including a 0%-coverage ABCI handler).

What was done?

67 new unit tests across 21 files. Applied the lesson from prior PRs: accessor tests barely move Codecov, so every test here targets an error path or edge case that integration tests don't hit.

Target Prev cov Missed Tests added
rs-drive-abci/abci/handler/check_tx.rs 0% 111 4
rs-drive-abci/execution/platform_events/core_chain_lock 69% 240 2
rs-drive-abci/config.rs 73% 114 17
rs-drive-abci/execution/platform_events/state_transition_processing 79% 256 3
rs-drive/drive/document/insert_contested 59% 430 3
rs-drive/drive/document/index_uniqueness 66% 362 8
rs-drive/drive/contract (insert + update) 67–72% 687 6
rs-drive/drive/group/fetch (9 submodules) 67% 341 24
rs-drive/drive/document/query 69% 269 5 (across 4 submodules)

Highlighted coverage wins

abci/handler/check_tx.rs (0% → covered) — the entire ABCI check_tx handler was untested. Covers BadRequest on invalid r#type, garbage-bytes InvalidEncoding + consensus code path, recheck label, empty-body rejection.

core_chain_lock/verify_chain_lock_locally_v0 — BLS DeserializationError arm on bad compressed signature bytes; verify_chain_lock_v0 maps that error into chain_lock_signature_is_deserializable: false.

config.rs (73% → covered) — every arm of from_str_to_network_with_aliases + Custom error; every arm of deserialize_quorum_type (name/numeric-string/unknown); url() composition helpers; default_for_network all 4 network dispatches; ValidatorSetConfig/ChainLockConfig/InstantLockConfig default_100_67 constructors + QuorumLikeConfig accessors; serialize_quorum_type; Default impls.

drive/contract (insert + update)update_contract ContractDoesNotExist CorruptedCodeExecution (v0 + v1), !apply short-circuit delegation to insert_contract, update_contract_description empty-existing add-new branch, update_contract_keywords add-only and delete-all branches, insert_contract_v1 zero-base-supply custom-destination path.

drive/document/insert_contestedDataContractNotFound, owner_id = None short-circuit, ContestedIndexNotFound on a doc type without contested indices (DPNS preorder).

drive/document/index_uniqueness (66% → covered) — v0/v1 public dispatcher happy paths on empty state; DuplicateUniqueIndexError on preorder collision; allow_original true/false branches; skip-incomplete-indices when where_queries < index.properties; skip non-unique indexes; v1 ChangedDocument unchanged-values allow-original vs changed-values flag-duplicate; exit_early on missing required timestamp.

drive/group/fetch (67% → covered, 24 tests across 9 submodules)fetch_group_info nonexistent Ok(None) + stateless vs stateful branches; fetch_group_infos limit=0 short-circuit, start-past-last, operations variant; fetch_action_infos closed-empty, zero-limit; fetch_action_signers empty variants; fetch_active_action_info Err on missing (exercises grove_get_raw_item error path), approximate_without_state_for_costs None, stateful Some; fetch_action_is_closed false in both branches; fetch_action_id_has_signer false + stateless; fetch_action_id_signers_power None/records ops; fetch_action_id_info_keep_serialized Err + stateless.

drive/document/queryquery_documents_v0 dry_run short-circuit, empty-contract Document::from_bytes loop, real-doc conversion path; outcome trait accessor defaults for contested storage + vote_state variants.

Production bugs flagged (out of scope, follow-up tasks spawned)

  1. Chain-lock height underflowpackages/rs-drive-abci/src/execution/platform_events/core_chain_lock/make_sure_core_is_synced_to_chain_lock/v0/mod.rs:26-27: the else branch is only reached when best_chain_locked_height < given_chain_lock_height, yet it computes best - given — causing a panic in debug or wraparound to a huge unsigned value in release. Operands need to be swapped. Potentially consensus-relevant depending on callers.

  2. random_document_with_params ignores required transferred_atDocumentType::random_document_with_params in rs-dpp unconditionally sets transferred_at, transferred_at_block_height, transferred_at_core_block_height to None even when those fields are in required_fields (e.g. DPNS domain). Callers hit DataContractError(MissingRequiredKey("transferred at field is not present")) on later serialize. Surfaced while writing uniqueness-violation tests.

How Has This Been Tested?

  • cargo test -p drive --lib 'drive::document::insert_contested' — 4 pass
  • cargo test -p drive --lib 'drive::document::index_uniqueness' — 8 pass
  • cargo test -p drive --lib 'drive::group::fetch' — 28 pass
  • cargo test -p drive --lib 'drive::document::query' — 15 pass
  • cargo test -p drive --lib 'drive::contract' — 98 pass
  • cargo test -p drive-abci --lib 'abci::handler::check_tx' — 4 pass
  • cargo test -p drive-abci --lib 'core_chain_lock' — 12 pass
  • cargo test -p drive-abci --lib 'config' — 52 pass
  • cargo test -p drive-abci --lib 'state_transition_processing' — 10 pass
  • cargo check --tests -p drive -p drive-abci — clean
  • cargo fmt -p drive -p drive-abci — clean

Breaking Changes

None. Tests 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

…onfig

Add 67 new unit tests across 21 files, focused on error paths and
branch conditions (per the lesson from prior PRs: accessor tests
move Codecov very little, because integration tests already cover
happy paths).

Per-target breakdown:

- rs-drive-abci/abci/handler/check_tx.rs (0% → covered, 4 tests):
  BadRequest on invalid r#type, garbage-bytes InvalidEncoding +
  consensus code path, recheck (type=1), empty-body rejection.

- rs-drive-abci/execution/platform_events/core_chain_lock/
  (69% → covered, 2 tests): verify_chain_lock_locally_v0 BLS
  DeserializationError arm on bad compressed signature bytes;
  verify_chain_lock_v0 maps that error into
  `chain_lock_signature_is_deserializable: false`.

- rs-drive-abci/config.rs (73% → covered, 17 tests): every arm of
  from_str_to_network_with_aliases + Custom error; every arm of
  deserialize_quorum_type (name/numeric-string/unknown); url()
  composition helpers; CoreConfig::Default; default_for_network
  all 4 network dispatches; ValidatorSetConfig / ChainLockConfig /
  InstantLockConfig default_100_67 constructors + QuorumLikeConfig
  accessors; serialize_quorum_type; PlatformConfig + ExecutionConfig
  Default.

- rs-drive-abci/execution/platform_events/state_transition_
  processing/validate_fees_of_event/v0 (79% → covered, 3 tests):
  Paid + PaidFromAssetLock with identity.balance = None →
  CorruptedCodeExecution; all fee-free event kinds short-circuit
  to default FeeResult.

- rs-drive/drive/contract (67–72% → covered, 6 tests):
  update_contract ContractDoesNotExist CorruptedCodeExecution
  (both v0 + v1), !apply short-circuit that delegates to
  insert_contract, update_contract_description empty-existing
  add_new_description branch, update_contract_keywords add-only
  and delete-all branches, insert_contract_v1 zero base_supply
  custom-destination path.

- rs-drive/drive/document/insert_contested (59% → covered, 3 tests):
  DataContractNotFound, owner_id = None short-circuit,
  ContestedIndexNotFound on a doc type without contested indices
  (DPNS preorder).

- rs-drive/drive/document/index_uniqueness (66% → covered, 8 tests):
  v0/v1 public dispatcher happy paths on empty state;
  DuplicateUniqueIndexError on preorder collision;
  allow_original true/false branches; skip-incomplete-indices when
  where_queries < index.properties; skip non-unique indexes;
  v1 ChangedDocument unchanged-values allow-original vs
  changed-values flag-duplicate; exit_early on missing required
  timestamp.

- rs-drive/drive/document/query (69% → covered, 5 tests):
  query_documents_v0 dry_run short-circuit, empty-contract
  Document::from_bytes loop, real-doc conversion path; outcome
  trait accessor defaults for contested storage + vote_state
  variants.

- rs-drive/drive/group/fetch (67% → covered, 24 tests across 9
  submodules): fetch_group_info nonexistent Ok(None) + stateless
  vs stateful branches; fetch_group_infos limit=0 short-circuit,
  start-past-last, operations variant; fetch_action_infos
  closed-empty, zero-limit; fetch_action_signers empty variants;
  fetch_active_action_info Err on missing (grove_get_raw_item),
  approximate_without_state_for_costs None, stateful Some;
  fetch_action_is_closed false in both stateful + stateless;
  fetch_action_id_has_signer false + stateless; fetch_action_id_
  signers_power None/records ops; fetch_action_id_info_keep_
  serialized Err + stateless.

Two production issues flagged via follow-up tasks:

1. A real underflow bug in packages/rs-drive-abci/src/execution/
   platform_events/core_chain_lock/make_sure_core_is_synced_to_
   chain_lock/v0/mod.rs:26-27 — the else branch subtracts
   best-minus-given when best is known to be less than given,
   causing a panic in debug or wraparound in release. Swap the
   operands.
2. packages/rs-dpp/src/data_contract/document_type random_document
   _with_params unconditionally sets transferred_at fields to None
   even when they're required — callers hit
   DataContractError(MissingRequiredKey) on later serialize.

All 67 tests pass. cargo fmt clean, cargo check --tests clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added this to the v3.1.0 milestone Apr 23, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 23, 2026

Warning

Rate limit exceeded

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

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 40 minutes and 46 seconds.

⌛ 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: ccd6eff2-528a-476a-9d7f-a176c4d0889b

📥 Commits

Reviewing files that changed from the base of the PR and between 3eaf388 and a59c180.

📒 Files selected for processing (21)
  • packages/rs-drive-abci/src/abci/handler/check_tx.rs
  • packages/rs-drive-abci/src/config.rs
  • packages/rs-drive-abci/src/execution/platform_events/core_chain_lock/verify_chain_lock/v0/mod.rs
  • packages/rs-drive-abci/src/execution/platform_events/core_chain_lock/verify_chain_lock_locally/v0/mod.rs
  • packages/rs-drive-abci/src/execution/platform_events/state_transition_processing/validate_fees_of_event/v0/mod.rs
  • packages/rs-drive/src/drive/contract/mod.rs
  • packages/rs-drive/src/drive/document/index_uniqueness/mod.rs
  • packages/rs-drive/src/drive/document/insert_contested/mod.rs
  • packages/rs-drive/src/drive/document/query/query_contested_documents_storage/v0/mod.rs
  • packages/rs-drive/src/drive/document/query/query_contested_documents_vote_state/v0/mod.rs
  • packages/rs-drive/src/drive/document/query/query_documents/v0/mod.rs
  • packages/rs-drive/src/drive/document/query/query_documents_with_flags/v0/mod.rs
  • packages/rs-drive/src/drive/group/fetch/fetch_action_id_has_signer/v0/mod.rs
  • packages/rs-drive/src/drive/group/fetch/fetch_action_id_info_keep_serialized/v0/mod.rs
  • packages/rs-drive/src/drive/group/fetch/fetch_action_id_signers_power/v0/mod.rs
  • packages/rs-drive/src/drive/group/fetch/fetch_action_infos/v0/mod.rs
  • packages/rs-drive/src/drive/group/fetch/fetch_action_is_closed/v0/mod.rs
  • packages/rs-drive/src/drive/group/fetch/fetch_action_signers/v0/mod.rs
  • packages/rs-drive/src/drive/group/fetch/fetch_active_action_info/v0/mod.rs
  • packages/rs-drive/src/drive/group/fetch/fetch_group_info/v0/mod.rs
  • packages/rs-drive/src/drive/group/fetch/fetch_group_infos/v0/mod.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/coverage-abci-handler-document-contract-group

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 23, 2026

Review Gate

Commit: a59c1804

  • Debounce: 39m ago (need 30m)

  • CI checks: build failure: JS packages (@dashevo/wasm-sdk) / Tests, JS packages (@dashevo/evo-sdk) / Tests, JS packages (@dashevo/wasm-dpp2) / Tests

  • CodeRabbit review: comment found

  • Off-peak hours: off-peak (09:42 PM PT Wednesday)

  • Run review now (check to override)

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

❌ Patch coverage is 97.99279% with 39 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.29%. Comparing base (3eaf388) to head (a59c180).
⚠️ Report is 3 commits behind head on v3.1-dev.

Files with missing lines Patch % Lines
...s-drive/src/drive/document/index_uniqueness/mod.rs 98.04% 9 Missing ⚠️
packages/rs-drive/src/drive/contract/mod.rs 96.02% 6 Missing ⚠️
...sition_processing/validate_fees_of_event/v0/mod.rs 95.45% 5 Missing ⚠️
packages/rs-drive-abci/src/config.rs 97.61% 4 Missing ⚠️
...s-drive/src/drive/document/insert_contested/mod.rs 98.10% 3 Missing ⚠️
...ackages/rs-drive-abci/src/abci/handler/check_tx.rs 96.92% 2 Missing ⚠️
...ore_chain_lock/verify_chain_lock_locally/v0/mod.rs 90.90% 2 Missing ⚠️
...ive/group/fetch/fetch_active_action_info/v0/mod.rs 98.23% 2 Missing ⚠️
...e/group/fetch/fetch_action_id_has_signer/v0/mod.rs 96.42% 1 Missing ⚠️
...tch/fetch_action_id_info_keep_serialized/v0/mod.rs 96.15% 1 Missing ⚠️
... and 4 more
Additional details and impacted files
@@             Coverage Diff              @@
##           v3.1-dev    #3516      +/-   ##
============================================
+ Coverage     87.04%   87.29%   +0.24%     
============================================
  Files          2474     2475       +1     
  Lines        283604   285547    +1943     
============================================
+ Hits         246863   249255    +2392     
+ Misses        36741    36292     -449     
Components Coverage Δ
dpp 86.26% <ø> (+0.02%) ⬆️
drive 86.61% <98.33%> (+0.39%) ⬆️
drive-abci 89.29% <96.63%> (+0.27%) ⬆️
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 92.10% <ø> (ø)
platform-wallet ∅ <ø> (∅)
drive-proof-verifier 55.66% <ø> (ø)
🚀 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 2b0438a into v3.1-dev Apr 23, 2026
103 of 119 checks passed
@QuantumExplorer QuantumExplorer deleted the test/coverage-abci-handler-document-contract-group branch April 23, 2026 04:51
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