Skip to content

feat: mock platform#258

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

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 cli host #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

Copy link
Copy Markdown
Author

Closing in favor of a clean re-port onto current main.

This branch (feat/mock-platform) was 131 commits ahead of main, sitting on
worktree-issue-96-rust-core-port, a base that has since been superseded — main
landed the Rust core through #248#256 / #252. The mock code here was written
against #104's API (FlatHostCallbacks, ProductRuntimeConfig), so rebasing it
would be a cascade of conflicts rather than a fast-forward.

The mock has been re-ported onto main's core as a single clean commit —
MockPlatform (behind the mock feature) + createMockHost (main's nested
RequiredHostCallbacks shape), with a wasm-bridge test driving the real WASM
core, and CI wired in. That work is up as #294 and closes the
re-port half of #257.

No work is lost: the re-port carries over everything mock-specific from here,
adapted to main's API; the only intentional drop is the through-core mock-wallet
harness, because main already provides the equivalent StubPlatform + SSO
builders in truapi-server/src/test_support.rs (converging those two doubles is
tracked in #43).

#261 (browser E2E harness + createMockClient) re-ports onto the re-port once it
lands — it's on the same #104 base, so it needs the same adaptation, not a clean
rebase. Full stack and merge order in #43.

@decrypto21 decrypto21 closed this Jul 20, 2026
decrypto21 added a commit that referenced this pull request Jul 20, 2026
Re-port of the TrUAPI mock host (#258) onto main. Main already has the core
(landed via #248-256/#252), so only the mock-specific additions come over,
adapted to main's core API:

- truapi-platform: MockPlatform behind the mock feature. PreimageHost is
  lookup-only (the core owns Bulletin submission), so submit_preimage /
  BulletinAllowanceSigner are dropped and content is seeded via
  insert_preimage. Types come from truapi::latest per crate convention.
- truapi-host: createMockHost returns the nested RequiredHostCallbacks shape
  (main's per-capability grouping, not #104's FlatHostCallbacks); preimage is
  lookup-only with an insertPreimage seeder; mockRuntimeConfig sets the new
  required bulletin genesis hash.
- wasm-bridge test drives the real WASM core through the mock callbacks.
- CI: @parity/truapi-host job builds the WASM and runs bun test with
  REQUIRE_WASM=1, wired into the ci-status gate.

The through-core mock-wallet harness from #258 is intentionally not ported:
main already provides the equivalent StubPlatform + SSO statement/frame
builders in truapi-server/src/test_support.rs.
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