Skip to content

feat: add walletkit-testkit crate for reusable e2e test helpers#430

Open
kilianglas wants to merge 14 commits into
mainfrom
feat/walletkit-testkit-crate
Open

feat: add walletkit-testkit crate for reusable e2e test helpers#430
kilianglas wants to merge 14 commits into
mainfrom
feat/walletkit-testkit-crate

Conversation

@kilianglas

Copy link
Copy Markdown
Contributor

Summary

Adds a new walletkit-testkit workspace crate that consolidates the end-to-end / test-support logic previously triplicated across walletkit-core's integration tests, the walletkit-cli binary, and external consumers (e.g. orb-tools). walletkit-cli is migrated to consume it.

The motivation: other services that interact with the World ID protocol via WalletKit (e.g. orb-tools) currently re-implement WalletKit's storage providers and on-chain proof logic by copy-pasting from the CLI. This crate exposes that surface as a reusable library so consumers can depend on it directly (by git rev) instead of duplicating it.

walletkit-testkit is not published (publish = false): it ships staging URLs and pre-registered test-RP / test-issuer private keys, and is intended to be consumed by git revision.

What's in the crate

  • envTestEnv config struct centralizing all staging fixtures (RP id/key, on-chain verifier address, World Chain RPC, faux-issuer URL + schema, local issuer key + schema). TestEnv::default() = staging; every field is overridable.
  • storage — reusable StorageProvider impls: InMemoryStorageProvider (ephemeral, XChaCha20Poly1305 keystore) and FsStorageProvider (filesystem, no-op keystore), plus store constructors and cleanup helpers.
  • authenticatorinit_authenticator (fs store + cached Groth16 + init_with_defaults) and register_account (init_or_registerleaf_index).
  • issuer — two interchangeable issuance strategies producing a shared IssuedTestCredential: issue_faux_credential (hosted faux issuer, HTTP, schema 128) and issue_local_credential (local EdDSA, schema 47, deterministic / no service dependency).
  • proofbuild_test_request (RP-signed, TestEnv-parameterized) and verify_proof_onchain + VerifyItemResult (against the WorldIDVerifier contract).
  • flowgenerate_and_verify_test_proof: high-level convenience wiring the full register → init → issue → prove → verify pipeline for either issuance strategy.

CLI migration

walletkit-cli now consumes the testkit instead of carrying its own copies:

  • Deleted provider.rs (storage now from walletkit_testkit::storage).
  • Removed the sol\! verifier binding, VerifyItemResult, verify_proof_onchain, build_test_request, issue_test_credential, and all staging constants — imported from the testkit.
  • CLI behaviour is unchanged; --rpc-url / --verifier-address are mapped onto a TestEnv.

Testing

  • New #[ignore]d staging e2e tests (tests/e2e.rs) exercise both issuance paths end-to-end and confirm on-chain verification. Both pass against staging.
  • All 17 existing walletkit-cli tests pass (including the generate-test-request tests that drive the migrated builder).
  • cargo clippy --workspace --all-targets, cargo fmt --check, cargo doc, and cargo build --workspace are all green.

Follow-ups (out of scope)

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.

1 participant