test(dpp): improve coverage for cbor canonical, json utils, and document accessors#3383
Merged
Merged
Conversation
…ent accessors Add comprehensive unit tests for four DPP utility modules with low coverage: - canonical.rs: Tests for CborCanonicalMap construction, insert/remove/ get/set operations, canonical sorting (RFC 7049), serialization round-trips, TryFrom/From impls, ValuesCollection trait, ReplacePaths trait, value_to_bytes, and value_to_hash with various CBOR value types. - json_value/mod.rs: Tests for all JsonValueExt trait methods including push, insert, remove, remove_into, get_string/u8/u32/u64/i64/f64/ bytes/bool, get_value/get_value_mut path navigation, get_value_by_path, remove_u32, add_protocol_version, remove_value_at_path_into, and free functions get_value_mut/get_value_from_json_path. - document_type/accessors/mod.rs: Tests for DocumentTypeV0Getters, DocumentTypeV0Setters, DocumentTypeV0MutGetters on DocumentType, DocumentTypeRef, and DocumentTypeMutRef. Also covers DocumentTypeV1Getters and DocumentTypeV1Setters on V0 variants (None/no-op behavior). - specialized_document_factory/v0/mod.rs: Tests for document creation with valid/invalid types, extended document creation, factory construction, and is_ownership_the_same helper. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v3.1-dev #3383 +/- ##
============================================
+ Coverage 75.87% 76.87% +1.00%
============================================
Files 2912 2914 +2
Lines 283860 287443 +3583
============================================
+ Hits 215375 220975 +5600
+ Misses 68485 66468 -2017
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue being fixed or feature implemented
Improves unit test coverage for four DPP utility modules that had low coverage:
util/cbor_value/canonical.rs(28.8% -> improved)util/json_value/mod.rs(22.8% -> improved)document/specialized_document_factory/v0/mod.rs(8.2% -> improved)data_contract/document_type/accessors/mod.rs(42.6% -> improved)What was done?
Added 160 new unit tests across four files:
canonical.rs(55 new tests):CborCanonicalMapconstruction (new,default,from_vector,from_serializable)to_value_unsorted,to_value_sorted,to_value_cloneTryFrom<CborValue>andFromimpls for Vec and BTreeMapValuesCollectiontrait (get,get_mut,remove)ReplacePathstrait (replace_paths,replace_path,get_path_mut)value_to_byteswith Bytes, Text (base58), Array, and error casesvalue_to_hashwith Bytes, Text (base58), Array, and error casesjson_value/mod.rs(52 new tests):JsonValueExttrait methods:push,insert,remove,remove_intoget_u8,get_u32,get_u64,get_i64,get_f64get_string,get_bytes,get_boolget_value,get_value_mut,get_value_by_path,get_value_by_path_mutremove_u32,add_protocol_version,remove_value_at_path_intoget_value_mut,get_value_from_json_path,get_value_from_json_path_mutinsert_with_pathfor deeply nested structure creationdocument_type/accessors/mod.rs(37 new tests):DocumentTypeV0Gettersmethods onDocumentType,DocumentTypeRef,DocumentTypeMutRefDocumentTypeV0Setters(set_data_contract_id) onDocumentTypeandDocumentTypeMutRefDocumentTypeV0MutGetters(schema_mut)DocumentTypeV1Getterson V0 variants (verify None/empty defaults)DocumentTypeV1Setterson V0 variants (verify no-op behavior)to_owned_document_typefrom refspecialized_document_factory/v0/mod.rs(10 new tests):is_ownership_the_samehelper with same, different, single, and empty ID setsHow Has This Been Tested?
All 164 tests pass with
cargo test -p dpp:Code was formatted with
cargo fmt -p dppand compiles without warnings.Breaking Changes
None. This PR only adds tests.
Checklist: