Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

Tests: a real v0.3.4 gdd-0.1 save still loads and replays identically (#2352)

Eyal Golan7fb0b47a92a8
diff --git a/sim/Statecraft.Sim.Tests/OldSaveCompatibilityTests.cs b/sim/Statecraft.Sim.Tests/OldSaveCompatibilityTests.cs
new file mode 100644
index 000000000..15043d47e
--- /dev/null
+++ b/sim/Statecraft.Sim.Tests/OldSaveCompatibilityTests.cs
@@ -0,0 +1,34 @@
+using System.IO;
+using Statecraft.Sim;
+
+/// <summary>
+/// The fixture is a real gdd-0.1 save written by v0.3.4. Replay drift under gdd-0.1 means a v0.3.4 player's save
+/// no longer loads identically; that is a release blocker, not a fixture to regenerate.
+/// </summary>
+public class OldSaveCompatibilityTests
+{
+ [Fact]
+ public void V034Gdd01SaveStillLoadsIdentically()
+ {
+ var content = ContentLoader.Load(RealContentTests.ContentRoot());
+ var repo = Directory.GetParent(RealContentTests.ContentRoot())!.FullName;
+ var path = Path.Combine(repo, "sim", "Statecraft.Sim.Tests", "saves", "v0.3.4-gdd01.txt");
+ var text = File.ReadAllText(path);
+
+ var saved = SaveGame.Parse(text);
+ Assert.Equal(SaveGame.GddRuleset, saved.Ruleset);
+
+ var loaded = GameSession.Load(content, text, out var warnings);
+
+ // The replay and the open turn first: with other content, drift only adds replay_differs, so checking the
+ // warnings first would hide which part drifted.
+ // If this fails after a deliberate gdd-0.1 rule or design-value change (a golden re-pin, docs/determinism.md),
+ // v0.3.4 players' saves no longer replay identically: they load with replay_differs (GameSession.Load). That needs an
+ // owner decision, not a fixture update or deleting this test (as #1780's hand-pinned hash tests were).
+ Assert.Equal(saved.FinalHash, loaded.State.Hash());
+ var order = Assert.IsType<UnitOrder>(Assert.Single(loaded.Committed));
+ Assert.Equal((3, Orders.Fortify), (order.Unit, order.Order));
+
+ Assert.Equal(new[] { GameSession.ContentChanged }, warnings);
+ }
+}
diff --git a/sim/Statecraft.Sim.Tests/saves/v0.3.4-gdd01.txt b/sim/Statecraft.Sim.Tests/saves/v0.3.4-gdd01.txt
new file mode 100644
index 000000000..7df570761
--- /dev/null
+++ b/sim/Statecraft.Sim.Tests/saves/v0.3.4-gdd01.txt
@@ -0,0 +1,28 @@
+statecraft-save 3
+content 162a08693f3d6873262f7006afee478d29e837435723d8edb88dde0e24c892b3
+seed 1948
+mode Historical
+ruleset gdd-0.1
+turn
+move 0 9 11
+work tel_aviv job 90
+train tel_aviv halutz 158
+turn
+move 0 8 11
+project housing haifa 6 9
+event first_truce accept
+turn
+capture nazareth occupy
+project industry haifa 7 9
+order 1 fortify
+turn
+dollars 1
+arms 10
+turn
+event latrun_proposal accept_vote
+order 2 hold
+turn
+event operation_yoav stop_at_ceasefire
+open
+order 3 fortify
+end 80b1596bd2509ad7c1a4a60cfc57abb5bfc380b4dede7a7e90df2c13fd53926f