Add gateway client integration, smoke, and E2E tests #10

Closed
opened 2026-02-27 14:35:35 +00:00 by mik-tf · 0 comments
Member

Problem

The gateway client integration has zero test coverage. The 33 existing unit tests only cover signing, shared types, and backend validation — none of the GatewayClient methods (account ops, token transfers, marketplace listings) are tested.

Solution — Three Test Layers

Layer 1: Integration Tests (wiremock)

New crates/gateway-tests/ crate with 23 tests using wiremock to mock the gateway's JSON-RPC /rpc endpoint:

  • Credential setup (mnemonic derivation, determinism, custom account ID, invalid mnemonic)
  • Health check
  • Account methods (exists, activate, get_balance, get_token_balance)
  • Token methods (storage_deposit, transfer, transfer_with_memo) — tests the two-step write flow
  • Marketplace methods (create_listing, list_by_farmer, get_listing_count)
  • Error handling (RPC errors, malformed JSON, network errors, no credentials, server 500)

Runs with make test-gateway or cargo test -p gateway-tests. No network needed.

Layer 2: Gateway Smoke Tests (bash/curl)

scripts/gateway-smoke-test.sh — follows existing smoke-test.sh pattern:

  • Gateway health + RPC discover
  • Account activation (public method)
  • Error handling (invalid method, malformed JSON, empty body)

Runs with make gateway-smoke-test. Requires network access to gateway.

Layer 3: E2E Browser Tests (Playwright)

e2e/ directory with Playwright setup:

  • App loads without WASM panic
  • Login button visible
  • No RefCell borrow panic on navigation
  • Wallet connect with mnemonic (via TEST_MNEMONIC env var)
  • Navigate after connecting (RefCell regression test)
  • Vault save and unlock flow

Runs with make test-e2e. Requires dx serve running on :8080.

Mnemonic is provided via TEST_MNEMONIC env var — never hardcoded. For CI, use a repo secret.

New Makefile Targets

  • test-gateway — wiremock integration tests
  • gateway-smoke-test — real gateway smoke tests
  • e2e-install — install Playwright + Chromium
  • test-e2e — run E2E browser tests
  • test-all updated to include test-gateway
## Problem The gateway client integration has zero test coverage. The 33 existing unit tests only cover signing, shared types, and backend validation — none of the `GatewayClient` methods (account ops, token transfers, marketplace listings) are tested. ## Solution — Three Test Layers ### Layer 1: Integration Tests (wiremock) New `crates/gateway-tests/` crate with 23 tests using wiremock to mock the gateway's JSON-RPC `/rpc` endpoint: - Credential setup (mnemonic derivation, determinism, custom account ID, invalid mnemonic) - Health check - Account methods (exists, activate, get_balance, get_token_balance) - Token methods (storage_deposit, transfer, transfer_with_memo) — tests the two-step write flow - Marketplace methods (create_listing, list_by_farmer, get_listing_count) - Error handling (RPC errors, malformed JSON, network errors, no credentials, server 500) Runs with `make test-gateway` or `cargo test -p gateway-tests`. No network needed. ### Layer 2: Gateway Smoke Tests (bash/curl) `scripts/gateway-smoke-test.sh` — follows existing `smoke-test.sh` pattern: - Gateway health + RPC discover - Account activation (public method) - Error handling (invalid method, malformed JSON, empty body) Runs with `make gateway-smoke-test`. Requires network access to gateway. ### Layer 3: E2E Browser Tests (Playwright) `e2e/` directory with Playwright setup: - App loads without WASM panic - Login button visible - No RefCell borrow panic on navigation - Wallet connect with mnemonic (via `TEST_MNEMONIC` env var) - Navigate after connecting (RefCell regression test) - Vault save and unlock flow Runs with `make test-e2e`. Requires `dx serve` running on :8080. Mnemonic is provided via `TEST_MNEMONIC` env var — never hardcoded. For CI, use a repo secret. ## New Makefile Targets - `test-gateway` — wiremock integration tests - `gateway-smoke-test` — real gateway smoke tests - `e2e-install` — install Playwright + Chromium - `test-e2e` — run E2E browser tests - `test-all` updated to include `test-gateway`
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mycelium/www_migrate_mycelium#10
No description provided.