test: cover abci handler, drive contract/document/group, drive-abci config#3516
Conversation
…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>
|
Warning Rate limit exceeded
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 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (21)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Review GateCommit:
|
Codecov Report❌ Patch coverage is 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
🚀 New features to boost your workflow:
|
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.
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-bytesInvalidEncoding+ consensus code path, recheck label, empty-body rejection.core_chain_lock/verify_chain_lock_locally_v0 — BLS
DeserializationErrorarm on bad compressed signature bytes;verify_chain_lock_v0maps that error intochain_lock_signature_is_deserializable: false.config.rs (73% → covered) — every arm of
from_str_to_network_with_aliases+ Custom error; every arm ofdeserialize_quorum_type(name/numeric-string/unknown);url()composition helpers;default_for_networkall 4 network dispatches;ValidatorSetConfig/ChainLockConfig/InstantLockConfigdefault_100_67constructors +QuorumLikeConfigaccessors;serialize_quorum_type; Default impls.drive/contract (insert + update) —
update_contractContractDoesNotExistCorruptedCodeExecution(v0 + v1),!applyshort-circuit delegation toinsert_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_contested —
DataContractNotFound,owner_id = Noneshort-circuit,ContestedIndexNotFoundon a doc type without contested indices (DPNS preorder).drive/document/index_uniqueness (66% → covered) — v0/v1 public dispatcher happy paths on empty state;
DuplicateUniqueIndexErroron preorder collision;allow_originaltrue/false branches; skip-incomplete-indices whenwhere_queries < index.properties; skip non-unique indexes; v1ChangedDocumentunchanged-values allow-original vs changed-values flag-duplicate;exit_earlyon missing required timestamp.drive/group/fetch (67% → covered, 24 tests across 9 submodules) —
fetch_group_infononexistentOk(None)+ stateless vs stateful branches;fetch_group_infoslimit=0short-circuit, start-past-last, operations variant;fetch_action_infosclosed-empty, zero-limit;fetch_action_signersempty variants;fetch_active_action_infoErron missing (exercisesgrove_get_raw_itemerror path),approximate_without_state_for_costsNone, stateful Some;fetch_action_is_closedfalse in both branches;fetch_action_id_has_signerfalse + stateless;fetch_action_id_signers_powerNone/records ops;fetch_action_id_info_keep_serializedErr + stateless.drive/document/query —
query_documents_v0dry_runshort-circuit, empty-contractDocument::from_bytesloop, real-doc conversion path; outcome trait accessor defaults for contested storage + vote_state variants.Production bugs flagged (out of scope, follow-up tasks spawned)
Chain-lock height underflow — 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
elsebranch is only reached whenbest_chain_locked_height < given_chain_lock_height, yet it computesbest - 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.random_document_with_params ignores required transferred_at —
DocumentType::random_document_with_paramsin rs-dpp unconditionally setstransferred_at,transferred_at_block_height,transferred_at_core_block_heighttoNoneeven when those fields are inrequired_fields(e.g. DPNSdomain). Callers hitDataContractError(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 passcargo test -p drive --lib 'drive::document::index_uniqueness'— 8 passcargo test -p drive --lib 'drive::group::fetch'— 28 passcargo test -p drive --lib 'drive::document::query'— 15 passcargo test -p drive --lib 'drive::contract'— 98 passcargo test -p drive-abci --lib 'abci::handler::check_tx'— 4 passcargo test -p drive-abci --lib 'core_chain_lock'— 12 passcargo test -p drive-abci --lib 'config'— 52 passcargo test -p drive-abci --lib 'state_transition_processing'— 10 passcargo check --tests -p drive -p drive-abci— cleancargo fmt -p drive -p drive-abci— cleanBreaking Changes
None. Tests only.
Checklist
For repository code-owners and collaborators only