Testing with createMockPlatform
Every integration test today needs the full Postgres/Redis/platform/operator stack running. createMockPlatform is a signable, in-memory stand-in for the platform's wallet/RGS endpoints that runs your ProviderClient code with no network at all.
import { createMockPlatform, ProviderClient } from '@moose/provider-sdk'
const mock = createMockPlatform({ secret: 'test-secret', tenantId: 'acme-studio' })
mock.registerSession({
sessionToken: 'sess-1',
playerRef: 'player-1',
gameId: 'book-of-acme',
operatorId: 'acme-casino',
currency: 'USD',
config: { rtpProfile: 'RTP_96_0', minBetMinor: 100, maxBetMinor: 10000, language: 'en' },
balanceMinor: 100000,
})
const client = new ProviderClient({
baseUrl: 'http://mock',
tenantId: 'acme-studio',
secret: 'test-secret',
fetch: mock.fetch, // the injection point — everything else about ProviderClient is unchanged
})
const session = await client.verifySession('sess-1') // resolves against the in-memory session above
const bet = await client.submitTransaction({ transactionId: crypto.randomUUID(), sessionToken: 'sess-1', type: 'BET', roundId: crypto.randomUUID(), roundComplete: false, playerRef: session.playerRef, amount: 500, currency: session.currency, gameId: session.gameId })It genuinely verifies the request signature against the secret you gave it — pointing a client with the wrong secret at the mock produces a real 401, the same as it would against the live platform, so a signing bug in your integration code still surfaces here instead of being silently accepted. It also mirrors the wallet contract at a simplified level: DECLINED on insufficient funds or a bet outside minBetMinor/ maxBetMinor, and idempotent replay of an already-seen transactionId without double-charging.
This is for your own integration tests, not a substitute for testing against the real platform before going live — the SDK's examples/smoke.ts is a real end-to-end connectivity check against a running platform instance, and the Go-live checklist covers what else to verify before your first real player session.
What the mock does and doesn't enforce
| Behavior | Mocked? |
|---|---|
Signature verification against the secret you passed in | Yes — a wrong secret 401s, same as the real platform |
DECLINED on insufficient funds or a bet outside bet limits | Yes, at a simplified level |
Idempotent replay of a seen transactionId | Yes — no double-charging |
| Rate limiting, secret rotation grace, nonce replay detection | No |
| Session revoke / free-spins webhooks (platform → provider) | No — these are calls your server receives, not something ProviderClient makes; test your webhook handlers directly with verifyPlatformSignature |
| Central Config resolution nuances (RTP profile catalogs, per-operator overrides) | No — registerSession's config is whatever you pass in |
Full reference
See createMockPlatform in the @moose/provider-sdk reference for the exact MockPlatformOptions and MockPlatform types.