Skip to content

Conversation

@m-005
Copy link
Member

@m-005 m-005 commented Jan 16, 2026

Summary

Add Tier 1 (identity) module to objects-test-utils and completely migrate objects-identity tests to use shared utilities. This is part 2 of the test utilities consolidation effort (PR1b).

Changes

New Functionality

  • src/identity.rs (200 lines): Identity factories with structured return types
    • RandomPasskeyIdentity and RandomWalletIdentity structs
    • test_identity_id() returns canonical "obj_2dMiYc8RhnYkorPc5pVh9"
    • random_passkey_identity() and random_wallet_identity() factories

Protocol Logic Enhancement

  • objects-identity/src/handle.rs: Exposed reserved handles as public API
    • Added Handle::reserved_handles()&'static [&'static str]
    • Added Handle::is_reserved(s: &str)bool
    • Moved protocol logic from test code to main crate

Test Migration

  • objects-identity/tests/integration_test.rs: Migrated all fixtures to use objects_test_utils::crypto
  • objects-identity/tests/property_test.rs: Updated to use Handle::reserved_handles() from main crate
  • Deleted: objects-identity/tests/common/mod.rs (80 lines eliminated)

Test Results

  • ✅ objects-test-utils: 41 tests passing (12 unit + 15 integration + 14 doctests)
  • ✅ objects-identity: 63 tests passing (22 unit + 29 integration + 11 property + 1 doctest)
  • ✅ Total: 104 tests passing
  • ✅ Zero clippy warnings with -D warnings
  • ✅ All code formatted

Migration Strategy

Clean migration with no backward compatibility stubs:

  • Deleted tests/common/mod.rs entirely
  • Moved protocol constants to proper location in main crate
  • All tests updated to use shared utilities directly

Verification

cargo build -p objects-test-utils
cargo test -p objects-test-utils
cargo test -p objects-identity
cargo clippy --workspace -- -D warnings

Related

…tests

Add Tier 1 (identity) module to objects-test-utils and completely migrate
objects-identity tests to use shared utilities. No backward compatibility
stubs - clean migration.

## objects-test-utils changes:

**New identity module:**
- RandomPasskeyIdentity / RandomWalletIdentity structured types
- test_identity_id() - Returns canonical test identity (obj_2dMiYc8RhnYkorPc5pVh9)
- random_passkey_identity() - Generate random P-256 identity
- random_wallet_identity() - Generate random secp256k1 identity

**Testing:**
- 7 new integration tests in self_test.rs
- 4 new doctests
- Total: 41 tests passing (up from 26 in PR1a)

## objects-identity changes:

**Main crate:**
- Add Handle::reserved_handles() - Expose protocol constants publicly
- Add Handle::is_reserved() - Check if handle is reserved
- Moves protocol logic from test-only code to main crate (proper location)

**Test migration:**
- integration_test.rs: Use objects_test_utils::{crypto, time, identity}
- property_test.rs: Use Handle::reserved_handles() from main crate
- Delete tests/common/mod.rs entirely (80 lines of duplication eliminated)
- All fixtures use crypto::passkey_keypair().signing_key
- All nonces use crypto::random_nonce()
- All timestamps use time::now()

**Clippy fixes:**
- Use range contains: (23..=25).contains(&len)
- Remove needless borrow: hex::encode([...].repeat(16))
- Collapse nested if with let binding

## Verification:

- objects-test-utils: 41 tests passing
- objects-identity: 63 tests passing (22 unit + 29 integration + 11 property + 1 doctest)
- Zero clippy warnings with -D warnings
- All code formatted

## Key decisions:

✅ No deprecated stubs - clean break from old test utilities
✅ Reserved handles moved to main crate (protocol logic, not test helpers)
✅ Foundation complete for PR2 (data), PR3 (transport), PR4 (sync)

Follows PR1b plan. Builds on PR1a (#15).
@claude
Copy link

claude bot commented Jan 16, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

m-005 added 2 commits January 15, 2026 21:51
Use crypto::deterministic_bytes() instead of string literal to match
the robust pattern used for challenge encoding. More realistic test
case that demonstrates proper byte array → hex encoding flow.
Add section on proper test data generation using deterministic_bytes()
and hex encoding instead of string literals. Ensures test data mirrors
production data flow (bytes → encoding).
@m-005 m-005 merged commit bbb61e7 into main Jan 16, 2026
5 checks passed
@m-005 m-005 deleted the feat/test-utils-identity branch January 16, 2026 02:54
m-005 added a commit that referenced this pull request Jan 16, 2026
…tests (#16)

* feat: Add identity module to test-utils and migrate objects-identity tests

Add Tier 1 (identity) module to objects-test-utils and completely migrate
objects-identity tests to use shared utilities. No backward compatibility
stubs - clean migration.

## objects-test-utils changes:

**New identity module:**
- RandomPasskeyIdentity / RandomWalletIdentity structured types
- test_identity_id() - Returns canonical test identity (obj_2dMiYc8RhnYkorPc5pVh9)
- random_passkey_identity() - Generate random P-256 identity
- random_wallet_identity() - Generate random secp256k1 identity

**Testing:**
- 7 new integration tests in self_test.rs
- 4 new doctests
- Total: 41 tests passing (up from 26 in PR1a)

## objects-identity changes:

**Main crate:**
- Add Handle::reserved_handles() - Expose protocol constants publicly
- Add Handle::is_reserved() - Check if handle is reserved
- Moves protocol logic from test-only code to main crate (proper location)

**Test migration:**
- integration_test.rs: Use objects_test_utils::{crypto, time, identity}
- property_test.rs: Use Handle::reserved_handles() from main crate
- Delete tests/common/mod.rs entirely (80 lines of duplication eliminated)
- All fixtures use crypto::passkey_keypair().signing_key
- All nonces use crypto::random_nonce()
- All timestamps use time::now()

**Clippy fixes:**
- Use range contains: (23..=25).contains(&len)
- Remove needless borrow: hex::encode([...].repeat(16))
- Collapse nested if with let binding

## Verification:

- objects-test-utils: 41 tests passing
- objects-identity: 63 tests passing (22 unit + 29 integration + 11 property + 1 doctest)
- Zero clippy warnings with -D warnings
- All code formatted

## Key decisions:

✅ No deprecated stubs - clean break from old test utilities
✅ Reserved handles moved to main crate (protocol logic, not test helpers)
✅ Foundation complete for PR2 (data), PR3 (transport), PR4 (sync)

Follows PR1b plan. Builds on PR1a (#15).

* fix: use deterministic_bytes for content_hash in test

Use crypto::deterministic_bytes() instead of string literal to match
the robust pattern used for challenge encoding. More realistic test
case that demonstrates proper byte array → hex encoding flow.

* docs: add test pattern guidance for cryptographic data

Add section on proper test data generation using deterministic_bytes()
and hex encoding instead of string literals. Ensures test data mirrors
production data flow (bytes → encoding).
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