paritytech / paritytech/host-api-test-sdk

Swap the mock engine to `@parity/truapi-host`

Open
#40 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2
Forks
1
Avg merge
3h 46m
Merged PRs (30d)
2

Description

Summary

Replace the mock's wire engine - hand-written @novasamatech/host-container - with the generated @parity/truapi-host dispatcher. Keep all value-add (dev-key derivation, real sr25519 signing, signing log, productAccounts pinning, RPC proxy, Playwright fixture, fault injection). Only the protocol layer changes.

Why now

product-sdk#186 goes direct to @parity/truapi, deleting @novasamatech/host-api(-wrapper). On merge, a migrated product emits the generated truapi envelope the current mock can't decode - so every migrating product loses its E2E harness unless the mock moves in lockstep.

Design

Swap flat container.handleXxx(...) registration to nested, versioned, tagged-union handlers via createTrUApiServer(provider, handlers). ~40 slots regroup under 15 services; legacy error classes map to generated tagged unions. The host-side iframe Provider (already built, src/truapi-engine/host-iframe-provider.ts) plugs straight in. The fault layer wraps the raw provider below the engine, so it's retained - and protocolVersion skew becomes implementable here.

Tasks
  • Drop in the host-side iframe Provider (built)
  • Replace createContainer with createTrUApiServer(provider, handlers); regroup ~40 slots into 15 nested services; map legacy errors → tagged unions
  • Port the chain.* set (14 handlers) - reuse the truapi-host-integration/chain-handlers.ts prototype (response/follow-item mapping to finish)
  • Rewrite the test product on the @parity/truapi client (the chunkiest part - it currently uses @novasamatech/host-api-wrapper)
  • Re-target the fault layer to truapi's wire (handshake = wire id 1 via decodeWireMessage); implement protocolVersion
  • Drop @novasamatech/host-container; bump major; update CHANGELOG/forum-post/README
Acceptance criteria
  • A product on migrated @parity/product-sdk-* E2E-tests green against the new-engine mock; existing integration tests pass; @novasamatech/host-container removed.
Sequencing

Must land in lockstep with / after product-sdk#186

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the built provider in src/truapi-engine/host-iframe-provider.ts and the chain prototype in truapi-host-integration/chain-handlers.ts. Trace createContainer and the test product's @novasamatech/host-api-wrapper usage before reviewing the fault layer and wire handshake handling. Done means migrated product E2E tests and existing integration tests pass, with @novasamatech/host-container removed.

Written by the indexing model from the issue text.

Assessment

Tech stack
playwright, typescript
Domain
api, testing-qa
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.