Skip to content

feat: mock platform#258

Draft
decrypto21 wants to merge 13 commits into
worktree-issue-96-rust-core-portfrom
feat/mock-platform
Draft

feat: mock platform#258
decrypto21 wants to merge 13 commits into
worktree-issue-96-rust-core-portfrom
feat/mock-platform

Conversation

@decrypto21

@decrypto21 decrypto21 commented Jul 1, 2026

Copy link
Copy Markdown

feat: mock host foundation — MockPlatform + mock wallet + createMockHost, on the real core

Summary

A mock host that swaps the seams while running the real Rust core. Tests, CI, and product
test-suites exercise the actual truapi-server dispatcher, permission service, storage, and
statement-store logic — with the device and wallet supplied by config-driven, in-memory doubles
instead of a real phone or paired wallet. Deterministic, deviceless, scriptable.

Why "swap the seam, keep the core"

TrUAPI is one core with two seams: the platform seam (truapi-platform capability traits) and
the wallet seam (SSO + statement store). The mock replaces only those seams. Because every
request still flows through the real core, the mock is faithful by construction — it can't drift
from real host semantics the way a hand-rolled fake would.

What this delivers

truapi-platformMockPlatform (behind the mock feature, dev-only)

  • MockConfig: permission policy (AllowAll/DenyAll, device + remote), feature support, theme,
    confirmation control, chain behavior (Silent / Scripted / Closed / ConnectError), and
    MockFaults error injection.
  • Implements every platform-seam trait, and records what the core asked the device to do
    (navigations, notifications, confirmations, auth-state, sent RPC) for assertions.

truapi-servermock_wallet (behind the mock feature)

  • MockWalletPlatform + MockWalletConnection: in-process, deterministic SSO pair + sign over
    the statement-store channel (sr25519 proofs, P-256 ECDH → HKDF → AES-GCM). It reuses the real
    statement-store signing helper, so it stays in lockstep with production framing. Slice-0:
    in-process-valid, not chain-valid — real on-chain signing is Headless pairing + signing hosts #264 (below).

Through-core proof — tests build the real core from the mock
(from_platform_with_config + SCALE) and assert on the wire envelopes the dispatcher emits.

truapi-host-wasmcreateMockHost — an in-memory HostCallbacks (tsc-enforced complete),
a headless WASM-bridge test proving the real WASM core drives the mock across JS↔SCALE↔WASM, and
a host-wasm CI job. (The one-line createMockClient + real-browser E2E are in #261.)

Relationship to the real headless host (#264) and simulation (#36)

This is the deterministic, deviceless tier. It is complementary to
#264
(a real headless pairing/signing host: real
People-chain statement store, real mnemonic signer) — #264 has no mock, this has no real signer, and
the two do not overlap. Real-chain and real-signing capabilities are deliberately deferred to #264,
not reimplemented here.
The simulation program
(sdk-team#36) builds on both: deterministic scale on
this mock, real-API runs through #264.

Status (rebased onto current #104, green)

Area State
truapi-platform (MockPlatform) ✅ 22 unit tests
truapi-server (mock_wallet + through-core) ✅ 267 pass · 2 parked (see below)
truapi-host-wasm (createMockHost + WASM bridge) ✅ 42 tests; tsc clean; fresh WASM bundle
Workspace fmt · clippy --all-features -D warnings · test --workspace --all-features

2 through-core tests parked (#[ignore]d + flagged, not deleted): the mock wallet's
signing-response framing and preimage-submit path depend on #104 SSO internals that are still in
flight (opaque SSO ids / statement-proof routing; preimage now needs a bulletin allowance signer).
Un-park once those settle.

Scope & safety

  • The mock feature is a dev-dependency only — never in the default/production build.
  • No change to real host behavior or the protocol surface.

Stacked on

#104 (Rust core port). Merge order: #104#258#261. Tracked by #257.

@decrypto21 decrypto21 changed the title Feat/mock platform feat: mock platform Jul 2, 2026
@decrypto21 decrypto21 force-pushed the feat/mock-platform branch 2 times, most recently from a3bd662 to 52e642f Compare July 2, 2026 22:15
@decrypto21 decrypto21 force-pushed the feat/mock-platform branch from 52e642f to c68127e Compare July 8, 2026 13:24
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