BF2.US bf2-rsdeveloper wiki Parity Discord bf2.us
On this page

The test rigs

BF22142Heroes

"Does it behave like the original?" is not one question. Does this function give the same bits? Does this vehicle end the slalom in the same place? Does a round end when the tickets run out? Each has its own rig, and each rig has its own reference: the original's code, the original server, or the game's own data.

Each layer catches what the one below cannot see floor static coverage and reachability every function of the original is ported, cited, or ruled out L1 function oracles the original's own function called in-process on crafted inputs; ours must give the same bits L2 wiring which cited functions really ran in play, on our client and on the original server L3 differentials the same inputs to our server and the original: soldier movement, vehicle drive, game rules L4 scenarios and invariants scripted rounds with headless players and real clients; no panic, hang or correction storm L5 sweeps every kit x item x action, every vehicle x seat x weapon, HUD and menu screens L6 soak and field bots that keep fighting for 30 game minutes, growth limits per level and round narrow at the top: few, slow, close to play. Wide at the bottom: many, fast, exact.
The layers. A fault found high up is expensive to find; the lower layers exist so that most faults never get there.

L1: the function oracle#

The oracle calls functions of the original executables in-process with crafted inputs and compares their outputs with our Rust for the same inputs, without running a game.

  • A small 32-bit host maps one original image per process, at its link base when that range is free. No entry point and no static initialiser of the image runs.
  • The image's imports are traps, except the C runtime it needs: a function that reaches for something the host did not give it fails its case instead of doing something.
  • A case names the function's address, its calling convention as read from the listing (this in ecx, stack words, a struct returned through a buffer, the custom register conventions of link-time code generation) and input vectors. The same vector goes to a generated Rust shim.
  • An access violation or a trap inside a call is a result (fault <code> at <address>), and the host goes on with the next call.
powershell
python tools\retail_oracle\retail_oracle.py run [--case ID] [-v]
cargo test -p retail-oracle-rs

A function with a passing oracle case counts as tested in the strict sense (parity numbers). The oracle suits pure functions best: arithmetic, curves, matrix products, the bit stream's primitives. It is how the float precision findings are held bit for bit.

Emulator rows

Where a function cannot be called whole (it needs a live object graph), one statement of it can still be held: the original's instructions for that statement are run in a CPU emulator over generated inputs, once per x87 control word, and the test holds ours to those rows (for example 600 rows, 300 a control word, for one sum of Heroes' heightmap walk). Such a test says which statement its rows hold and that the function is not held whole.

L3: differentials against the original server#

The same inputs go to our server and to the original dedicated server, and the outputs are compared.

RigInputsComparedReference
soldier movementrecorded player actionsthe soldier's position, every tickcaptures of 543 and 776 ticks
vehicle drive (the vehicle replay)recorded driving: a slalom, a ramevery vehicle's node state, every tickcaptures of 500 and 1,227 ticks
player action sweep519 cases of a kit, an item and an actionwhat the server sends backthe original server, side by side on 127.0.0.1
game rulesheadless players that play a scriptscores, tickets, the round's end, squads, votes, teams, chat, awardsthe original server

The vehicle replay is the strictest of them: after a change to the physics, "the whole vehicle replay identical" means that not one float of one node moved in any tick of any capture. A change that is meant to move something says which rows moved and why.

L4: scenarios#

A scenario is a small file that starts a server on a level, adds headless players or real clients, plays a script (keys, waits, console commands) and asserts on what it finds: the server's state, a client's trace lines, a screenshot's pixels, the packets.

powershell
tools\scenarios\run.ps1 smoke -Parallel 3 -PortBase <base>
python tools\scenarios\scn.py run bfh_client_widget_sweep

Every scenario also runs the invariants, whatever it asserts itself: no panic, no hang, no unclassified error line, no correction storm, no pop in the sound, no sound that failed to resolve, the frame time and the tick rate within their limits.

SuiteWhatAbout
smoke7 scenarios4 to 10 minutes; on every merge
wall_a, wall_bthe regression wall: one scenario per fault that was once found in play11 minutes each
actions21 kit tours12 minutes
vehicles95 minutes
hud, menus14 and 311 and 4 minutes
fulleverythingabout an hour, three at a time

A scenario can run its client as the desktop program or as the page in a headless browser, with the same script. That is how the browser client is held to the desktop's behaviour.

L5: sweeps#

Sweeps are generated, not written: every kit with every item and every action; every vehicle with every seat and every weapon; every HUD screen and menu; and the picture sweep, which replays a client's frames on a reference Direct3D 9 device and compares the pictures.

L2 and the floor#

  • Static coverage asks whether every function of the original is ported (cited by address in the Rust), ruled out of scope, or library code. It has been complete for every binary since October 2026, which is why it stopped being a useful number and the parity count took its place.
  • Wiring asks which of the cited functions really ran in play, on our client and, with a tracer, on the original server. A ported function that never runs is a function nobody has seen work.

L6: soak#

Bots that must keep fighting for 30 game minutes on a fast-forwarded server; rotations of levels with limits on what may grow per level, per round and per minute, beside the original server's memory over the same rotation.

Which rig for which question#

You changedRun
arithmetic in a ported functionits oracle case and its crate's tests, in both precisions
the soldier's or a vehicle's physicsthe movement differential, the vehicle replay
a game rule, a score, a spawnthe gp_* differentials, the scenario of that rule
the network layoutthe bit-stream and join tests of bf2-net
something a player sees or hearsa scenario with a client; the picture or the HUD sweep
the browser clientthe same scenario as a page; the browser smoke

Rules every check follows#

  • 127.0.0.1 only, and our own servers only.
  • Clients run off screen with injected input; every process ends within 5 minutes of wall time.
  • The original client never runs as a program in a check: only its code, inside the oracle's host.
  • A fix lands with a check that fails before it and passes after it; "matches the original" needs a check that runs.
  • An expected failure is listed with the open row behind it, and the summary says when the entry can go.

Which rig a new port meets in which order: how a port is made.

Notes: notes/tracks/validation-quickref.md, notes/tracks/validation-strategy.md, notes/retail_oracle.md, notes/tracks/scenarios.md.

Each rig in depth: the oracle, scenarios, sweeps, the wall and soak.

How it is tested#

Each rig's reference is named in its table above. The vehicle replay's captures are fixed files: a physics change either leaves every float of every tick identical or says which rows moved and why.

In the code#

The crates this page names, each with its line of docs/release/LAYOUT.md (the list is gathered by the wiki's build from the page itself):

CrateWhat it is
crates/bf2-netthe wire-compatible network protocol
Source: docs/dev/testing/rigs.md · built from bf2-rs e3b4f05 · part of the Battlefield 2 / 2142 / Heroes reimplementation. Not affiliated with EA or DICE.