test(sdk): comprehensive coverage boost for iota-sdk-types and iota-sdk-crypto #596
Open
abhiraj-mengade wants to merge 1 commit into
Open
Conversation
3 tasks
abhiraj-mengade
force-pushed
the
feature/test-coverage-improvements
branch
6 times, most recently
from
February 17, 2026 04:52
8e49e42 to
d1b67c4
Compare
Achieved a total coverage improvement of +5.10% across the targeted crates. Breakdown by Crate: - `iota-sdk-types`: Increased by ~11.6% (from ~68.9% to 80.5%). - `iota-sdk-crypto`: Increased by ~0.9% (from ~96.2% to 97.1%). Total Impact: - Combined Coverage: 92.1% (+5.1%). - Net New Covered Lines: +2,418.
abhiraj-mengade
force-pushed
the
feature/test-coverage-improvements
branch
from
February 17, 2026 04:54
d1b67c4 to
4b0417a
Compare
Alex6323
reviewed
Mar 17, 2026
Comment on lines
+320
to
+329
| fn test_intent_creation_accessors() { | ||
| let intent = Intent::new( | ||
| IntentScope::TransactionData, | ||
| IntentVersion::V0, | ||
| IntentAppId::Iota, | ||
| ); | ||
| assert_eq!(intent.scope(), IntentScope::TransactionData); | ||
| assert_eq!(intent.version(), IntentVersion::V0); | ||
| assert_eq!(intent.app_id(), IntentAppId::Iota); | ||
| } |
Alex6323
reviewed
Mar 17, 2026
Comment on lines
+166
to
+169
| #[cfg(test)] | ||
| mod tests_accessors { | ||
| use super::*; | ||
| use crate::{ |
Contributor
There was a problem hiding this comment.
accessor testing is not really useful
Alex6323
reviewed
Mar 17, 2026
Comment on lines
+917
to
+962
| #[test] | ||
| fn test_object_in_accessors() { | ||
| let digest = mock_digest(); | ||
| let owner = mock_owner(); | ||
| let version = 10; | ||
|
|
||
| let obj = ObjectIn::Data { version, digest, owner }; | ||
|
|
||
| assert_eq!(obj.version(), version); | ||
| assert_eq!(obj.digest(), digest); | ||
| assert_eq!(obj.owner(), owner); | ||
|
|
||
| assert_eq!(obj.version_opt(), Some(version)); | ||
| assert_eq!(obj.digest_opt(), Some(digest)); | ||
| assert_eq!(obj.owner_opt(), Some(owner)); | ||
|
|
||
| let missing = ObjectIn::Missing; | ||
| assert!(missing.version_opt().is_none()); | ||
| assert!(missing.digest_opt().is_none()); | ||
| assert!(missing.owner_opt().is_none()); | ||
| } | ||
|
|
||
| #[test] | ||
| #[should_panic(expected = "object does not exist")] | ||
| fn test_object_in_panic_version() { | ||
| ObjectIn::Missing.version(); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_object_out_accessors() { | ||
| let digest = mock_digest(); | ||
| let owner = mock_owner(); | ||
| let version = 20; | ||
|
|
||
| // ObjectWrite | ||
| let obj = ObjectOut::ObjectWrite { digest, owner }; | ||
| assert_eq!(obj.object_digest(), digest); | ||
| assert_eq!(obj.object_owner(), owner); | ||
| assert!(obj.package_version_opt().is_none()); | ||
|
|
||
| // PackageWrite | ||
| let pkg = ObjectOut::PackageWrite { version, digest }; | ||
| assert_eq!(pkg.package_version(), version); | ||
| assert_eq!(pkg.package_digest(), digest); | ||
| assert!(pkg.object_owner_opt().is_none()); | ||
| } |
Contributor
There was a problem hiding this comment.
I think you can remove all basic accessor testing (i.e. ctor assigns to field, accessor returns field value). Only if there's some actual logic involved producing the return value I would keep it.
Alex6323
reviewed
Mar 17, 2026
Comment on lines
+146
to
+153
| #[test] | ||
| fn test_config_new() { | ||
| let addr = Address::ZERO; | ||
| let id = ObjectId::ZERO; | ||
| let config = IotaNamesConfig::new(addr, id, addr, id, id); | ||
| assert_eq!(config.package_address, addr); | ||
| assert_eq!(config.object_id, id); | ||
| } |
Alex6323
reviewed
Mar 17, 2026
Comment on lines
+1813
to
+1815
| #[cfg(test)] | ||
| #[cfg(test)] | ||
| mod serialization_tests { |
Alex6323
reviewed
Mar 17, 2026
Comment on lines
+155
to
+157
| #[test] | ||
| // Sequential execution implied as we modify env vars globally | ||
| fn test_config_from_env() { |
Contributor
There was a problem hiding this comment.
You can remove this test. You are essentially testing something (std::env) instead of IotaNamesConfig. It's not worth it introducing unsafe and possible UB.
Alex6323
reviewed
Mar 17, 2026
Alex6323
left a comment
Contributor
There was a problem hiding this comment.
You can remove all tests, that only test:
- simple accesors
- derived traits
- std or dependencies rather than actual SDK logic
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.
Summary
This PR significantly improves test coverage across the core SDK crates, specifically targeting
iota-sdk-typesandiota-sdk-cryptowith an overall ~5.1% increase. ~109 new unit tests** were added, providing comprehensive validation for multisig verification, transaction effects, and cryptographic logic.📈 Coverage Impact
iota-sdk-typesiota-sdk-crypto(Note:
iota-sdk-cryptohas a high baseline due to large generated constant files, but critical logical components like multisig saw massive improvements from 0% to ~75%)Key Module Improvements
iota-sdk-crypto/multisig.rs):0%→75.1%— Fully covered threshold validation, signature aggregation, and bitmap logic.iota-sdk-types/framework.rs):0%→100%— Complete coverage forCoinstructs and object conversions.iota_namesmodules):~0%→~93%— Covered registry, configuration, and name record expiration logic.effects/mod.rs):~60%→92%— Added exhaustive accessor tests for transaction effects.gas.rs):~30%→95%— Added comprehensive tests forGasCostSummarycomputation.🛠 Changes Overview
iota-sdk-typesImprovementsframework.rs(Coin),gas.rs, andiota_namesspecific logic.TransactionEffectsenum accessors ineffects/mod.rsandv1.rs.NameRecordserialization iniota_names/registry.rs.hash.rsaddress derivation (zkLogin, etc.) andmove_package.rsupgrade policies.iota-sdk-cryptoImprovementsMultisigVerifier, bitmap operations, and public key aggregation.bls12381(+42%),ed25519(+45%),secp256k1(+43%), andsecp256r1(+43%).✅ Verification
All tests passed with
--all-features:Closes #504