Skip to main content
@subsquid/pipes/testing provides utilities for testing pipes end-to-end without hitting a real portal:
  • mockPortal({ blocks, latest?, finalized? }): spin up a local HTTP server that answers every query (including restarts, forks, and finalized streams) from a chain of blocks, the way the real portal does. Resolves to { url, close(), ... }; pass url as the stream’s portal.
  • mockPortal(responses): spin up a local HTTP server that plays back scripted portal responses in order.
  • readAll(stream): drain a stream into a flat array of data items.
For Solana there are no typed block builders yet; construct portal responses as raw block objects. Each response entry mirrors the portal wire format: a header plus the requested data items (instructions, transactions, etc.).

Example (Vitest)

Mock response types

mockPortal accepts an array of scripted responses, played back in order:
The 409 variant lets you test fork handling deterministically, and 500/503 let you exercise retry behavior.