Registry / testing / yellowstone-grpc-mock

yellowstone-grpc-mock

JSON →
library0.1.4jsnpmunverified

A Jest mock for @triton-one/yellowstone-grpc that emits real serialized on-chain data, including SPL token account layouts and Metaplex metadata. v0.1.4 enables integration tests that exercise the full deserialization pipeline, not just business logic after parsing. It serializes byte layouts using runtime libraries (@solana/spl-token, @metaplex-foundation/mpl-token-metadata) and wraps them in valid SubscribeUpdate protobufs streamed via a Duplex. The mock starts playback on the first SubscribeRequest, mirroring real Geyser stream behavior. Key differentiators: tests edge cases like self-transfers, zero-amount mints, and frozen states; ships TypeScript types; requires peer deps be installed separately.

npm install yellowstone-grpc-mock
INSTALL
IMPORT
SIG · YELLOWSTONE-GRPC-M
Y
yellowstone-grpc-mock
testingjavascriptv0.1.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

YellowStoneMock
import { YellowStoneMock } from 'yellowstone-grpc-mock'
const { YellowStoneMock } = require('yellowstone-grpc-mock')
ESM-only; CommonJS require will fail. Use ESM imports or configure tsconfig accordingly.
MockClient
import { MockClient } from 'yellowstone-grpc-mock'
MockClient is not a named export; it's part of the jest.mock setup
MockClient is only accessible inside jest.mock() via require('yellowstone-grpc-mock').MockClient.
mintedNFT
import { mintedNFT } from 'yellowstone-grpc-mock/actions'
import { mintedNFT } from 'yellowstone-grpc-mock'
Action factories are in a subpath export 'yellowstone-grpc-mock/actions', not the main entry.
transferNFT
import { transferNFT } from 'yellowstone-grpc-mock/actions'
import { transferNFT } from 'yellowstone-grpc-mock'
Action factories are in a subpath export 'yellowstone-grpc-mock/actions', not the main entry.

Shows basic mock setup: create YellowStoneMock, push action factories for mint and transfer, end stream, and use with mock client.

import { YellowStoneMock } from 'yellowstone-grpc-mock'; import { mintedNFT, transferNFT, transferSPL, slotUpdate } from 'yellowstone-grpc-mock/actions'; const MINT = 'GkNkuozgNFN7K5AAjmFjMSFnNegpqkwEGbJyEXGq7LYR'; const WALLET1 = '5ByhkuHZMH7sU36DhfNMjy78hSMTPKJ1UEdDJqoKkmrU'; const WALLET2 = '9nJ7BWiAsNEHzFBtNXLFKFuJJupCdMwZ6xGZZNYPumpE'; it('counts hold slots on transfer', async () => { const ysm = new YellowStoneMock(); ysm .push(mintedNFT(MINT, WALLET1)) .push(transferNFT(MINT, WALLET1, WALLET2)) .push(slotUpdate()) .end(); const client = new (require('@triton-one/yellowstone-grpc').default)('https://mock', 'token'); // ... indexer logic expect(client).toBeDefined(); });
Debug
Known issues
breakingESM only – CommonJS require() will throw ERR_REQUIRE_ESM
fix
Use ESM imports (import { YellowStoneMock } from 'yellowstone-grpc-mock') or configure your test runner to support ESM (e.g., --experimental-vm-modules in Node).
affects: >=0.1.0
gotchaPeer dependencies must be installed separately; not bundled
fix
Run npm install @solana/spl-token @metaplex-foundation/mpl-token-metadata bs58
affects: >=0.1.0
gotchaAction factory imports must use subpath 'yellowstone-grpc-mock/actions', not main entry
fix
Use import { mintedNFT } from 'yellowstone-grpc-mock/actions'
affects: >=0.1.0
gotchaMockClient is not exported as named export; only accessible via jest.mock and require()
fix
Use jest.mock('@triton-one/yellowstone-grpc', () => { const { MockClient } = require('yellowstone-grpc-mock'); return { __esModule: true, default: MockClient }; })
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find package 'yellowstone-grpc-mock' imported from ...
Package not installed or missing from node_modules
fix
Run npm install --save-dev yellowstone-grpc-mock
ERR_REQUIRE_ESM
Using CommonJS require() to import an ESM-only package
fix
Replace require('yellowstone-grpc-mock') with import ... from 'yellowstone-grpc-mock'
Cannot find module '@solana/spl-token' or its corresponding type declarations.
Missing peer dependency
fix
Run npm install @solana/spl-token
Upgrade
Version history
0.1.4latest on npm
Audit
Dependencies
@solana/spl-tokenoptionalPeer dependency for serializing SPL token account layouts
@metaplex-foundation/mpl-token-metadataoptionalPeer dependency for serializing Metaplex metadata
bs58optionalPeer dependency for base58 encoding/decoding
Agent activity
21 hits · last 30 days
node
20
OpenAI (training)
1
Resources
yellowstone-grpc-mock — npm install yellowstone-grpc-mock · libregistry