Skip to content

test: increase test coverage by 16% across 3 crates#970

Open
Nuel-osas wants to merge 1 commit intoiotaledger:developfrom
Nuel-osas:test/increase-coverage-bounty-504
Open

test: increase test coverage by 16% across 3 crates#970
Nuel-osas wants to merge 1 commit intoiotaledger:developfrom
Nuel-osas:test/increase-coverage-bounty-504

Conversation

@Nuel-osas
Copy link
Copy Markdown
Contributor

Summary

Adds 387 unit tests across 16 files in 3 crates, increasing line coverage from 47.84% to 64.08% (+16.24%).

Targets meaningful logic rather than trivial getters:

  • iota-sdk-types (+178 tests): ZkLogin claim verification (verify_extended_claim, JwtHeader::from_base64, ZkLoginInputs::new), passkey authenticator validation & serialization roundtrips, MoveAuthenticator construction/address extraction/serialization, MultisigCommittee is_valid() validation, Bn254FieldElement encoding, event/object types
  • iota-sdk-transaction-builder (+138 tests): TransactionBuilder API (gas config, commands, send_coins), ULEB128 encoding & MoveArgCollection BCS serialization, gas station version parsing, unresolved transaction types, error variants
  • iota-sdk-graphql-client (+71 tests): TryFrom<BigInt> for u64 conversion with overflow/error cases, pagination utilities (Page::map, into_parts), error type system, faucet types, stream helpers

All tests are fully offline and self-contained. See TEST_COVERAGE.md for detailed breakdown.

Closes #504

Test plan

  • cargo +nightly test -p iota-sdk-types --lib --all-features — 536 passed, 0 failed
  • cargo +nightly test -p iota-sdk-transaction-builder --lib — 139 passed, 8 failed (pre-existing, require localnet)
  • cargo +nightly test -p iota-sdk-graphql-client --lib — 75 passed, 32 failed (pre-existing, require GraphQL endpoint)
  • Coverage measured with cargo-llvm-cov: 47.84% → 64.08%

Add comprehensive unit tests targeting meaningful logic across
iota-sdk-types, iota-sdk-transaction-builder, and iota-sdk-graphql-client.
Line coverage increases from 47.84% to 64.08% (+16.24%).

Key areas tested:
- ZkLogin claim verification, JWT header parsing, Bn254FieldElement encoding
- Passkey authenticator validation and serialization roundtrips
- MoveAuthenticator construction, address extraction, serialization
- ULEB128 encoding and MoveArgCollection BCS serialization
- TransactionBuilder API, gas configuration, and command generation
- BigInt-to-u64 conversion with overflow/error handling
- Gas station version parsing and comparison
- Pagination utilities, error types, faucet types, stream helpers
- MultisigCommittee is_valid() validation logic
- Unresolved transaction types and error variants

All 387 new tests are fully offline and self-contained.
@Nuel-osas Nuel-osas requested a review from a team as a code owner February 18, 2026 09:14
@thibault-martinez
Copy link
Copy Markdown
Member

FYI this is a global bump of 3.3%
image

Comment thread TEST_COVERAGE.md
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 necessary to commit this file tbh

Comment on lines +551 to +560
#[test]
fn object_reference_new_and_accessors() {
let obj_id = ObjectId::ZERO;
let version = 42u64;
let digest = Digest::ZERO;
let obj_ref = ObjectReference::new(obj_id, version, digest);
assert_eq!(*obj_ref.object_id(), obj_id);
assert_eq!(obj_ref.version(), version);
assert_eq!(*obj_ref.digest(), digest);
}
Copy link
Copy Markdown
Contributor

@Alex6323 Alex6323 Mar 17, 2026

Choose a reason for hiding this comment

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

not a useful test

Comment on lines +574 to +579
#[test]
fn object_reference_clone_and_eq() {
let r1 = ObjectReference::new(ObjectId::ZERO, 1, Digest::ZERO);
let r2 = r1.clone();
assert_eq!(r1, r2);
}
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 a useful test

Comment on lines +581 to +586
#[test]
fn object_reference_ne_different_version() {
let r1 = ObjectReference::new(ObjectId::ZERO, 1, Digest::ZERO);
let r2 = ObjectReference::new(ObjectId::ZERO, 2, Digest::ZERO);
assert_ne!(r1, r2);
}
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 +197 to +198
#[cfg(test)]
mod 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.

IMHO you can remove those tests.

Comment on lines +100 to +102
#[cfg(test)]
mod tests {
use super::*;
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.

IMHO we don't need those tests

Comment on lines +198 to +199
assert_eq!(bc.amount, 1000);
assert!(bc.amount > 0);
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.

😂

Comment on lines +83 to +85
#[cfg(test)]
mod tests {
use super::*;
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 don't think there's a useful test in here. Can probably remove them all.

Copy link
Copy Markdown
Contributor

@Alex6323 Alex6323 left a comment

Choose a reason for hiding this comment

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

Can you please remove all tests, that just test:

  1. constructors
  2. derives (Clone, Copy, Eq)
  3. displays (for errors, ...)
  4. enum variants
  5. constants

I'ld rather have lower coverage than to maintain a lot of tests that never actually test something meaningful. Thanks You!

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%

3 participants