Skip to content

feat: mock platform#258

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

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

Conversation

@decrypto21

Copy link
Copy Markdown

Summary

Adds a mock host that swaps the platform seam while running the real Rust core. Tests and demos exercise the actual truapi-server dispatcher, account management, permission service, signing orchestration, and SCALE wire — with device/wallet capabilities supplied by an in-memory, config-driven double instead of a real device or paired wallet.

Why "swap the seam, keep the core"

TrUAPI is one core with two seams: the platform seam (truapi-platform capability traits — the OS/device primitives the core delegates) and the wallet seam (keys in a paired wallet over SSO). The mock replaces only the platform seam. 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 drives behavior: permission policies (AllowAll / DenyAll), chain behaviors (Silent / Scripted / Closed / ConnectError), confirmation control (ConfirmKind), and fault injection (MockFaults: storage / navigation / preimage / …).
  • Implements every capability trait (ProductStorage, CoreStorage, Navigation, Notifications, Permissions, Features, ChainProvider / JsonRpcConnection, AuthPresenter, UserConfirmation, ThemeHost, PreimageHost) against the core's async_trait surface and truapi::latest types.

truapi-server — through-core proof

  • Tests build the real core from a MockPlatform and assert on the SCALE wire envelopes the dispatcher emits: feature-support dispatch, storage round-trip, device-permission policy (DenyAllgranted: false), preimage confirm-gate, and storage-fault surfacing.

truapi-host-wasmcreateMockHost

  • In-memory HostCallbacks for browser / Web Worker host tests, a headless WASM-bridge test, and CI wiring.

Proven, not asserted

The mock is validated through the real core, never in isolation: the truapi-server tests decode the dispatcher's actual wire output, so a mock that diverged from real host semantics would fail them.

Scope & safety

  • The mock feature is a dev-dependency only — it never enters the default (production WASM) build.
  • No change to real host behavior or the protocol surface.

Stacked on

#104 (Rust-core port). This branch rebases onto #104's current head — review / merge #104 first.

Status

Area State
truapi-platform (MockPlatform) ✅ green — 22 mock unit tests, clippy/fmt clean
truapi-server (through-core) ✅ green — 214 tests incl. 5 through-core
truapi-host-wasm (createMockHost) 🚧 finalizing against #104's reworked worker callbacks + WASM rebuild

Test plan

cargo test -p truapi-platform --features mock
cargo test -p truapi-server --lib
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo +nightly fmt --check

Tracking

Roadmap and follow-ups under #257.

@decrypto21 decrypto21 changed the title Feat/mock platform feat: mock platform Jul 2, 2026
@decrypto21 decrypto21 force-pushed the feat/mock-platform branch from 1831740 to aad062e Compare July 2, 2026 08:50
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