Our engine reproduces the finishing stacks of 10,000 out of 10,000 real Pluribus hands. Tables still froze. The bugs weren't in any hand. They were in the space between hands, which no hand history ever tests. So we built a fuzzer that plays whole sessions, checked it against rules that must always hold, and open-sourced it as poker-session-fuzzer.

Why hand histories miss it

Hand-history corpora (PHH, site histories, solver output) are wonderful for testing betting, side pots and showdowns. But every hand in them starts from a known state: these players, in these seats, with this button and these blinds. The step that produces that state never runs:

That step is where our live table freezes came from.

Other engines don't help much as an oracle, because most of them also model one hand at a time. And multi-hand site histories disagree with each other on dead-button and missed-blind rules, so comparing against them mostly finds rule differences, not bugs.

No oracle needed

Instead of asking "what's the right answer?", the fuzzer asks "is anything impossible true?" It plays random sessions of cash games and sit-and-gos, with 2 to 9 seats and short stacks so players bust often. Players join and leave, sit in and out, time out, and climb the blind levels. Most moves come from each player's own legal actions. After every action it checks invariants:

It drives our engine through the exact JSON path our chain uses, rebuilding the game from serialized state on every action. Bugs where the in-memory engine is right but the serialized state loses something have bitten us before, so that matters.

What it found

Its first sweep, 200 sessions in about four seconds, found real bugs straight away. Two had already been fixed in the engine and released to mainnet by the time we wrote this, so we can describe them:

It also found a handful of seating-transition bugs that are still open. All of them are ways a table can stop dealing when players sit down, sit out or leave at particular moments. Each is filed with a reproduction, and we'll write them up once they're fixed. Finally, it showed that a fix we'd just merged for collapsed blind positions was only partial: hits dropped from 46 sessions in 200 to 9, which is a useful kind of feedback to get within minutes.

200Sessions per sweep
~4sSweep time in CI
2Chip-losing bugs fixed and live
5Open bugs filed with repros

Keeping CI green without hiding bugs

A fuzzer that fails on every known bug is a fuzzer people turn off. So known bugs are listed by issue number. Their violations are counted and play continues, and only a new kind of violation fails the run. When a fix lands, its entry is removed, and from then on the sweep guards it.

From a random byte stream to a readable test

A fuzz failure is a stream of random bytes, which nobody wants to debug. So every failure prints the session as a script, flags any action the engine accepted that wasn't in the player's legal actions, and renders the session as a scenario in our test language, poker-scene-dsl. The fuzzer's clock and the scenario's clock tick identically, so the scenario replays the session exactly. We checked this on all 200 sweep sessions. The fuzzer then minimises it automatically, replaying smaller and smaller pieces of the session until only the actions that matter are left. One 113-action table stall comes down to 12 sentences, ready to commit as a test.

Try it on your engine

The harness doesn't know anything about our engine. You implement two methods, tell me the table and apply this action, map the vocabulary to your engine's, and add three one-line tests: a sweep for CI, a replay for debugging, and a Go fuzz target for overnight runs. If your engine handles anything between hands (busts, the button, sitting out, late joins), there's a good chance this finds something.

poker-session-fuzzer is MIT-licensed.

A worked adapter, in Go and in TypeScript

Here is the whole surface the fuzzer asks an engine for. Two methods, and a vocabulary of plain poker words for actions, statuses and rounds. Everything below is in the poker-session-fuzzer README, and the only part you write is the mapping.

// What the fuzzer needs from any engine. Nothing else. type Table interface { State() sessionfuzz.State // seats, stacks, statuses, legal actions, positions Apply(sessionfuzz.Action) error // reject with an error and leave the table unchanged }

For an engine written in Go, the adapter is one file in your test package. The left-hand side of each mapping is the fuzzer's; the right-hand side is whatever your engine calls things. The three one-line tests at the bottom are the sweep for CI, the replay for debugging one seed, and the Go fuzz target for long runs.

// mytable_test.go — adapt your own Go engine. Names on the right are yours. type myTable struct{ g *myengine.Game } func newMyTable(c sessionfuzz.Config) (sessionfuzz.Table, error) { g, err := myengine.New(c.MaxPlayers, c.SmallBlind, c.BigBlind) return &myTable{g: g}, err } // Your statuses → the fuzzer's plain-English ones. var status = map[myengine.Status]sessionfuzz.Status{ myengine.InHand: sessionfuzz.Active, myengine.Folded: sessionfuzz.Folded, myengine.AllIn: sessionfuzz.AllIn, myengine.Bust: sessionfuzz.Busted, myengine.Away: sessionfuzz.SittingOut, } func (t *myTable) State() sessionfuzz.State { s := sessionfuzz.State{ Round: round(t.g.Street()), HandNumber: t.g.Hand(), NextToAct: t.g.ToAct(), Dealer: t.g.Button(), SmallBlind: t.g.SBSeat(), BigBlind: t.g.BBSeat(), Pot: t.g.Pot(), } for _, p := range t.g.Players() { s.Players = append(s.Players, sessionfuzz.Player{ Address: p.ID, Seat: p.Seat, Stack: p.Stack, Status: status[p.Status], Legal: legal(p), // each legal action with its min and max }) } return s } func (t *myTable) Apply(a sessionfuzz.Action) error { switch a.Action { // "fold", "call", "raise", "join", "leave", "sit-out", "new-hand", "deal", … case sessionfuzz.ActJoin: return t.g.Seat(a.Player, a.Seat, a.Amount) case sessionfuzz.ActNewHand: return t.g.NewHand(a.Deck) // the fuzzer supplies the deck, so a session replays exactly default: return t.g.Act(a.Player, a.Action, a.Amount) } } var engine = sessionfuzz.EngineFunc(newMyTable) var opts = sessionfuzz.Options{ Known: []sessionfuzz.KnownIssue{{ID: "#42", Match: regexp.MustCompile(`stall-at-end`)}}, // open bug: count it, don't fail } func TestSessionSweep(t *testing.T) { sessionfuzz.Sweep(t, engine, opts) } // 200 sessions, plain go test func TestSessionReplay(t *testing.T) { sessionfuzz.Replay(t, engine, opts) } // SESSIONFUZZ_SEED=n func FuzzSession(f *testing.F) { sessionfuzz.Fuzz(f, engine, opts) } // go test -fuzz

An engine written in TypeScript plugs in the same way, with one extra piece: the engine runs in Node behind a small bridge that reads one JSON request per line and writes one response per line. The bridge does the mapping in TypeScript, so your engine's types never leak into Go. Big integers travel as strings.

// bridge.ts — your TypeScript engine behind a JSON-lines bridge. // One request per line on stdin, one response per line on stdout. import { createInterface } from "node:readline"; import { MyEngine, Status } from "./engine"; const STATUS: Record<Status, string> = { // your vocabulary → the fuzzer's inHand: "active", folded: "folded", allIn: "all-in", bust: "busted", away: "sitting-out", waiting: "sitting-in", }; let table: MyEngine; function view() { // the same shape as sessionfuzz.State return { round: table.street(), // "preflop" | "flop" | "turn" | "river" | "showdown" | "end" handNumber: table.hand(), nextToAct: table.toAct(), dealer: table.button(), smallBlind: table.sbSeat(), bigBlind: table.bbSeat(), pot: table.pot().toString(), // big integers travel as strings players: table.players().map(p => ({ address: p.id, seat: p.seat, stack: p.stack.toString(), status: STATUS[p.status], legal: p.legalActions().map(a => ({ action: a.kind, min: a.min?.toString(), max: a.max?.toString() })), })), }; } for await (const line of createInterface({ input: process.stdin })) { const req = JSON.parse(line); let out; try { if (req.op === "create") table = new MyEngine(req.maxPlayers, req.smallBlind, req.bigBlind); else table.apply(req.player, req.action, req.amount, req.deck); // throw to reject out = { state: view() }; } catch (e) { out = { error: String(e) }; // the fuzzer treats this as "rejected, table unchanged" } process.stdout.write(JSON.stringify(out) + "\n"); }

The Go side of that pair is a table that starts node once, sends every Apply over stdin and decodes the state that comes back. It is the same shape as the Go adapter above, with the mapping on the other side of the pipe.

// tstable_test.go — the Go side: start node once per table, speak JSON lines. func newTSTable(c sessionfuzz.Config) (sessionfuzz.Table, error) { cmd := exec.Command("node", "bridge.js") in, _ := cmd.StdinPipe() outPipe, _ := cmd.StdoutPipe() t := &tsTable{in: in, out: bufio.NewScanner(outPipe)} return t, errors.Join(cmd.Start(), t.call(map[string]any{ "op": "create", "maxPlayers": c.MaxPlayers, "smallBlind": c.SmallBlind.String(), "bigBlind": c.BigBlind.String(), })) } func (t *tsTable) Apply(a sessionfuzz.Action) error { return t.call(map[string]any{"op": "apply", "player": a.Player, "action": a.Action, "amount": a.Amount.String(), "seat": a.Seat, "deck": a.Deck}) } func (t *tsTable) State() sessionfuzz.State { return t.last } // decoded from the last response func (t *tsTable) call(req map[string]any) error { b, _ := json.Marshal(req) t.in.Write(append(b, '\n')) t.out.Scan() var resp struct{ State *wireState; Error string } json.Unmarshal(t.out.Bytes(), &resp) if resp.Error != "" { return errors.New(resp.Error) } t.last = resp.State.toFuzz() // strings back to *big.Int, statuses to sessionfuzz.Status return nil }

This is not hypothetical. The scene DSL repository ships a complete, working bridge of exactly this shape for poker-engine-ts, an open-source TypeScript engine: adapters/pokerenginets holds bridge.mjs and the Go adapter that drives it. Copy the pair, swap in your engine, and run:

go get github.com/block52/poker-session-fuzzer go test -run TestSessionSweep ./... # deterministic, for CI SESSIONFUZZ_SEED=49 go test -run TestSessionReplay -v ./... # print one session in full go test -run '^$' -fuzz FuzzSession -fuzztime 10m ./... # coverage-guided, overnight

If a sweep fails, the output is a session script, the final table, and a minimised poker-scene-dsl scenario you can paste straight into a test. If it passes, add the known-issue list as bugs appear and let it run every night.

Want to build a poker platform?

We build provably fair, real-money poker where every hand is shuffled by verifiable randomness and settled on a public blockchain. We'd love to hear about your project.

Get in Touch