EpochSim.Testing
0.3.1
dotnet add package EpochSim.Testing --version 0.3.1
NuGet\Install-Package EpochSim.Testing -Version 0.3.1
<PackageReference Include="EpochSim.Testing" Version="0.3.1" />
<PackageVersion Include="EpochSim.Testing" Version="0.3.1" />
<PackageReference Include="EpochSim.Testing" />
paket add EpochSim.Testing --version 0.3.1
#r "nuget: EpochSim.Testing, 0.3.1"
#:package EpochSim.Testing@0.3.1
#addin nuget:?package=EpochSim.Testing&version=0.3.1
#tool nuget:?package=EpochSim.Testing&version=0.3.1
<div align="center">
EpochSim
Find the seed that breaks your simulation. A deterministic tick engine for .NET 10: fuzz by seed, replay any run, bisect to the first tick that diverges.
English · Русский
</div>
A simulation that cannot be reproduced cannot be debugged. EpochSim fixes the inputs of every tick: the same seed and the same commands always produce the same state, and a divergence is located to a single tick.
- Seed fuzzing.
Epoch.Fuzzruns your code on thousands of seeds, names the failing seed and tick, and shows which state fields changed. Failures shrink to a minimal command scenario. - Deterministic by construction. A run is defined by its state, seed and ordered input. Systems execute in a fixed order on one simulation thread.
- Replay and bisect. Verify a run against recorded fingerprints and find the first tick where an invariant breaks.
- Test-framework agnostic.
SimAssertworks in xUnit, NUnit and MSTest and turns found bugs into regression tests. - Roslyn analyzer. Flags wall-clock time,
Random, threads and other sources of non-determinism in simulation code. - CLI. Run, inspect, verify, replay, bisect and fuzz from the terminal.
Installation
dotnet add package EpochSim
dotnet add package EpochSim.Testing
dotnet tool install --global EpochSim.Cli
Requires .NET 10. EpochSim.All brings the whole module graph as a single dependency.
Find a bug by seed
Epoch.Fuzz needs no rewrite of existing code. Call it from Step, state what must always hold in Invariant, pick the seeds.
using EpochSim;
var report = Epoch.Fuzz<Inventory>(f => f
.State(() => new Inventory())
.Step((inventory, ctx) => inventory.Tick(ctx.Rng.AsRandom()))
.Invariant("StockNonNegative", inventory => inventory.Stock >= 0)
.Seeds(1, 1000)
.Ticks(500));
report.ThrowIfFailed();
public sealed class Inventory
{
public int Stock { get; private set; } = 5;
public void Tick(Random random)
{
if (random.Next(0, 3) == 0)
Stock += 4;
var demand = random.Next(0, 3);
if (Stock >= demand)
Stock -= demand;
if (random.Next(0, 400) == 0)
Stock -= 5;
}
}
The run finds the seeds on which the stock goes negative and names the tick and the state fields that changed:
Fuzz failed: Failures=21, SeedsRun=1000, ElapsedMs=150
[InvariantViolation] seed=18 tick=19
StockNonNegative: predicate returned false
StateDiff:
$.Stock: 1 -> -2
Repro: .Seeds(18, 18).Ticks(19)
...
Add .Seeds(18, 18).Ticks(19) from the Repro line to run only that failure. More in Fuzzing.
Run a simulation
using EpochSim;
var state = new WorldState();
var engine = Epoch.CreateEngine<WorldState>();
engine.AddSystem("World", tick: ctx => ctx.State.Population++);
using var run = Epoch.QuickRun(state, rootDir: "artifacts");
run.RunTicks(engine, seed: 1, endTickInclusive: 100);
Console.WriteLine(state.Population);
public sealed class WorldState
{
public int Population { get; set; }
}
Presets, external input, sessions and artifacts are covered in Embedding.
Test it
using EpochSim.Testing;
SimAssert.IsDeterministic<WorldState>(f => f
.State(() => new WorldState())
.Step((world, _) => world.Population++)
.Seeds(1, 50)
.Ticks(200));
public sealed class WorldState
{
public int Population { get; set; }
}
A failure names the seed, the tick and the changed state fields. More in Testing.
Command line
epochsim fuzz --adapter fuzzbug --seeds 1..1000
epochsim verify-run artifacts <runId>
epochsim bisect artifacts <runId>
epochsim failures list
Documentation
| Guide | Contents |
|---|---|
| Embedding | Presets, hosts, servers, external input |
| Fuzzing | Seeds, shrinking, failure store, CLI, CI |
| Testing | SimAssert, golden fingerprints, regression tests |
| Determinism | Rules and the analyzer ESIM001-ESIM006 |
| Sessions | Long-lived loops and stepping |
| Artifacts | Run directory layout and file formats |
Runnable examples are in src/EpochSim.Samples.
Development
dotnet build EpochSim.slnx -m:1
dotnet test EpochSim.slnx -m:1
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- EpochSim (>= 0.3.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.3.1 | 83 | 11/10/2026 |