Skip to content

test(sdk): comprehensive coverage boost for iota-sdk-types and iota-sdk-crypto #596

Open
abhiraj-mengade wants to merge 1 commit into
iotaledger:developfrom
abhiraj-mengade:feature/test-coverage-improvements
Open

test(sdk): comprehensive coverage boost for iota-sdk-types and iota-sdk-crypto #596
abhiraj-mengade wants to merge 1 commit into
iotaledger:developfrom
abhiraj-mengade:feature/test-coverage-improvements

Conversation

@abhiraj-mengade

@abhiraj-mengade abhiraj-mengade commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR significantly improves test coverage across the core SDK crates, specifically targeting iota-sdk-types and iota-sdk-crypto with an overall ~5.1% increase. ~109 new unit tests** were added, providing comprehensive validation for multisig verification, transaction effects, and cryptographic logic.

📈 Coverage Impact

Scope / Crate Base This PR Net Improvement
iota-sdk-types ~68.9% ~80.5% +11.6%
iota-sdk-crypto ~96.2% ~97.1% +0.9%
Targeted Area ~87.0% ~92.1% +5.1%

(Note: iota-sdk-crypto has 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

  • Multisig (iota-sdk-crypto/multisig.rs): 0%75.1% — Fully covered threshold validation, signature aggregation, and bitmap logic.
  • Framework (iota-sdk-types/framework.rs): 0%100% — Complete coverage for Coin structs and object conversions.
  • IOTA Names (iota_names modules): ~0%~93% — Covered registry, configuration, and name record expiration logic.
  • Transaction Effects (effects/mod.rs): ~60%92% — Added exhaustive accessor tests for transaction effects.
  • Gas Logic (gas.rs): ~30%95% — Added comprehensive tests for GasCostSummary computation.

🛠 Changes Overview

iota-sdk-types Improvements

  • Core Logic: Added unit tests for framework.rs (Coin), gas.rs, and iota_names specific logic.
  • Transaction Effects: Implemented tests for TransactionEffects enum accessors in effects/mod.rs and v1.rs.
  • Serialization: Enhanced coverage for NameRecord serialization in iota_names/registry.rs.
  • Utilities: Added missing tests for hash.rs address derivation (zkLogin, etc.) and move_package.rs upgrade policies.

iota-sdk-crypto Improvements

  • Multisig: Implemented robust tests for MultisigVerifier, bitmap operations, and public key aggregation.
  • Cryptographic Primitives: Added tests for bls12381 (+42%), ed25519 (+45%), secp256k1 (+43%), and secp256r1 (+43%).
  • ZKLogin: Maintained high coverage (~82%) while verifying new helper functions.

✅ Verification

All tests passed with --all-features:

test result: ok. 498 passed; 0 failed; 0 ignored; finished in 76.14s

Closes #504

@abhiraj-mengade
abhiraj-mengade requested a review from a team as a code owner February 16, 2026 20:38
@abhiraj-mengade abhiraj-mengade changed the title test(sdk): improve test coverage for core types and crypto test(sdk): comprehensive coverage boost for iota-sdk-types and iota-sdk-crypto Feb 16, 2026
@abhiraj-mengade
abhiraj-mengade force-pushed the feature/test-coverage-improvements branch 6 times, most recently from 8e49e42 to d1b67c4 Compare February 17, 2026 04:52
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
abhiraj-mengade force-pushed the feature/test-coverage-improvements branch from d1b67c4 to 4b0417a Compare February 17, 2026 04:54
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);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not useful

Comment on lines +166 to +169
#[cfg(test)]
mod tests_accessors {
use super::*;
use crate::{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accessor testing is not really useful

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());
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be removed

Comment on lines +1813 to +1815
#[cfg(test)]
#[cfg(test)]
mod serialization_tests {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate

Comment on lines +155 to +157
#[test]
// Sequential execution implied as we modify env vars globally
fn test_config_from_env() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Alex6323 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove all tests, that only test:

  1. simple accesors
  2. derived traits
  3. std or dependencies rather than actual SDK logic

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.

[Bounty] Increase test coverage by 5%

2 participants