feat: mock platform#258
Conversation
a3bd662 to
52e642f
Compare
…in, JS oracle parity
…igner, new review/storage variants)
…ductRuntimeConfig, WasmPairingHostRuntime, mock.dot id)
52e642f to
c68127e
Compare
|
Closing in favor of a clean re-port onto current This branch ( The mock has been re-ported onto main's core as a single clean commit — No work is lost: the re-port carries over everything mock-specific from here, #261 (browser E2E harness + |
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.
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-serverdispatcher, permission service, storage, andstatement-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-platformcapability traits) andthe 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-platform—MockPlatform(behind themockfeature, dev-only)MockConfig: permission policy (AllowAll/DenyAll, device + remote), feature support, theme,confirmation control, chain behavior (
Silent/Scripted/Closed/ConnectError), andMockFaultserror injection.(navigations, notifications, confirmations, auth-state, sent RPC) for assertions.
truapi-server—mock_wallet(behind themockfeature)MockWalletPlatform+MockWalletConnection: in-process, deterministic SSO pair + sign overthe 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-wasm—createMockHost— an in-memoryHostCallbacks(tsc-enforced complete),a headless WASM-bridge test proving the real WASM core drives the mock across JS↔SCALE↔WASM, and
a
host-wasmCI job. (The one-linecreateMockClient+ 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)
truapi-platform(MockPlatform)truapi-server(mock_wallet+ through-core)truapi-host-wasm(createMockHost+ WASM bridge)tscclean; fresh WASM bundlefmt·clippy --all-features -D warnings·test --workspace --all-features2 through-core tests parked (
#[ignore]d + flagged, not deleted): the mock wallet'ssigning-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
mockfeature is a dev-dependency only — never in the default/production build.Stacked on
#104 (Rust core port). Merge order: #104 → #258 → #261. Tracked by #257.