Skip to content

Implement proper Arbitrary trait for ZkLoginInputs property testing#553

Draft
Copilot wants to merge 8 commits intomove-core-sdkfrom
copilot/implement-todo-in-lib-rs
Draft

Implement proper Arbitrary trait for ZkLoginInputs property testing#553
Copilot wants to merge 8 commits intomove-core-sdkfrom
copilot/implement-todo-in-lib-rs

Conversation

Copy link
Contributor

Copilot AI commented Feb 2, 2026

The Arbitrary implementation for ZkLoginInputs used hardcoded test values instead of generating them dynamically, limiting property-based test coverage.

Changes

  • ZkLoginClaim generation: Generates random issuer values, creates properly formatted extended claims ("iss":"https://<random>.example.com",), and encodes as base64url. Uses index_mod_4 = 0 to avoid bit padding complexity.

  • JWT header generation: Dynamically creates and base64url-encodes valid JWT headers with required alg, kid, and typ fields.

Before/After

// Before: hardcoded values
let iss_base64_details = ZkLoginClaim {
    value: "wiaXNzIjoiaHR0cHM6Ly9pZC50d2l0Y2gudHYvb2F1dGgyIiw".to_owned(),
    index_mod_4: 2,
};
let header_base64 = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjEifQ".to_owned();

// After: dynamic generation
let iss_claim_strategy = ("[a-z]{10,50}").prop_map(|iss_value| {
    let extended_claim = format!(r#""iss":"https://{}.example.com","#, iss_value);
    let value = Base64UrlUnpadded::encode_string(extended_claim.as_bytes());
    ZkLoginClaim { value, index_mod_4: 0 }
});

All 367 tests pass with the new implementation.

Original prompt

Work on TODO: write this implementation (from crates/iota-sdk-types/src/lib.rs)

Created from VS Code via the GitHub Pull Request extension.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

DaughterOfMars and others added 6 commits February 2, 2026 09:21
* feat: Use Version struct over type def

* bindings and doc test

* replace sequence number mentions

* bindings again

* regenerate

* kotlin lib without prefix

* Apply suggestions from code review

* centralize cfg_attr tags

* bindings

* fix version in gas station data

* fix gas station string or num

* use Version everywhere

* privatize consts

* make `Version` private

* fix docs

* implement PartialEq and PartialOrd traits for Version and u64

* allow deserializing from number or string

* fix BCS deserialization

* derives

* revert some changes with serialization

* Remove schemars tag from version

---------

Co-authored-by: Thibault Martinez <thibault@iota.org>
#529)

* feat(types): enhance Address with system package constants and methods

- Add GENESIS_BRIDGE and STARDUST system package constants
- Rename from_u8 to from_u16 to support larger package IDs
- Add is_system_package() method
- Add const fn from_object_id conversion
- Add random() method behind 'rand' feature flag
- Add next_lexicographical method
- Rename into_inner/inner to into_bytes/bytes for consistency

* fix some issues

* bindings

* update random address generation to exclude wasm32 target

* Update crates/iota-sdk-types/src/address.rs

Co-authored-by: Thoralf-M <46689931+Thoralf-M@users.noreply.github.com>

* dedup

---------

Co-authored-by: Thoralf-M <46689931+Thoralf-M@users.noreply.github.com>
* feat(types): enhance ObjectId with system constants and methods

- Add GENESIS_BRIDGE and STARDUST system package constants
- Add const fn from_address conversion
- Add from_bytes constructor
- Add next_lexicographical method
- Add random() method behind 'rand' feature flag
- Rename into_inner/inner to into_bytes/bytes for consistency

* add ObjectId::MAX

* add ObjectId::from_u16

* Divide from_hex and from_short_hex

* add ObjectId::is_system_package

* refactor hex methods

* update bindings

* add more ObjectId constants

* add from_prefixed_hex and from_prefixed_short_hex

* update bindings

* increase UniffiLibBatch2 size

* fix Address FromStr so that non-prefixed short strings are not accepted

* bindings

* improve object id debug

---------

Co-authored-by: /alex/ <alexander.schmidt@iota.org>
- Add GENESIS constant for genesis digest marker
- Add UpperHex formatting support
- Add const fn improvements (inner, as_bytes, from_bytes)
- Add is_alive, is_deleted, is_wrapped methods for ObjectDigest
- Add next_lexicographical method
- Add random() method behind 'rand' feature flag
Copilot AI and others added 2 commits February 2, 2026 15:01
- Replace hardcoded values with proper property-based test generation
- Generate valid base64url-encoded JWT headers dynamically
- Generate valid ZkLoginClaim values with proper iss field encoding
- All tests passing including serialization_proptests

Co-authored-by: DaughterOfMars <18284021+DaughterOfMars@users.noreply.github.com>
Add explanatory comments for why fixed values are used for index_mod_4
and JWT header fields in the property-based testing implementation

Co-authored-by: DaughterOfMars <18284021+DaughterOfMars@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement TODO in lib.rs for iota-sdk-types Implement proper Arbitrary trait for ZkLoginInputs property testing Feb 2, 2026
Copilot AI requested a review from DaughterOfMars February 2, 2026 15:08
@DaughterOfMars DaughterOfMars force-pushed the feat/digest-improvements branch from 668d54f to c3c9c67 Compare February 3, 2026 08:37
Base automatically changed from feat/digest-improvements to move-core-sdk February 3, 2026 10:53
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.

2 participants