feat: mock platform#258
Draft
decrypto21 wants to merge 11 commits into
Draft
Conversation
…in, JS oracle parity
1831740 to
aad062e
Compare
a3bd662 to
52e642f
Compare
This was referenced Jul 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a mock host that swaps the platform seam while running the real Rust core. Tests and demos exercise the actual
truapi-serverdispatcher, 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-platformcapability 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-platform—MockPlatform(behind themockfeature, dev-only)MockConfigdrives behavior: permission policies (AllowAll/DenyAll), chain behaviors (Silent/Scripted/Closed/ConnectError), confirmation control (ConfirmKind), and fault injection (MockFaults: storage / navigation / preimage / …).ProductStorage,CoreStorage,Navigation,Notifications,Permissions,Features,ChainProvider/JsonRpcConnection,AuthPresenter,UserConfirmation,ThemeHost,PreimageHost) against the core'sasync_traitsurface andtruapi::latesttypes.truapi-server— through-core proofMockPlatformand assert on the SCALE wire envelopes the dispatcher emits: feature-support dispatch, storage round-trip, device-permission policy (DenyAll→granted: false), preimage confirm-gate, and storage-fault surfacing.truapi-host-wasm—createMockHostHostCallbacksfor 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-servertests decode the dispatcher's actual wire output, so a mock that diverged from real host semantics would fail them.Scope & safety
mockfeature is a dev-dependency only — it never enters the default (production WASM) build.Stacked on
#104 (Rust-core port). This branch rebases onto #104's current head — review / merge #104 first.
Status
truapi-platform(MockPlatform)truapi-server(through-core)truapi-host-wasm(createMockHost)Test plan
Tracking
Roadmap and follow-ups under #257.