test(battle-node): TurnEnd cycle can fire multiple times

Locks the loop invariant: after the first cycle the phase resets to
AfterReady, so the next player TurnEnd matches the same case arm and
produces the same two-frame burst.
This commit is contained in:
gamer147
2026-06-01 15:01:19 -04:00
parent e30fdb7570
commit decdef29cf

View File

@@ -120,6 +120,26 @@ public class BattleSessionDispatchTests
Assert.That(s.Phase, Is.EqualTo(BattleSessionPhase.AfterReady));
}
[Test]
public void TurnEnd_CanFireMultipleTimesConsecutively()
{
var s = NewSession();
s.ComputeResponses(NewEnvelope(NetworkBattleUri.InitNetwork));
s.ComputeResponses(NewEnvelope(NetworkBattleUri.InitBattle));
s.ComputeResponses(NewEnvelope(NetworkBattleUri.Loaded));
s.ComputeResponses(NewEnvelope(NetworkBattleUri.Swap));
var first = s.ComputeResponses(NewEnvelope(NetworkBattleUri.TurnEnd));
var second = s.ComputeResponses(NewEnvelope(NetworkBattleUri.TurnEnd));
// Both calls produce the same two-frame burst.
Assert.That(first.Select(r => r.Envelope.Uri),
Is.EqualTo(new[] { NetworkBattleUri.TurnStart, NetworkBattleUri.TurnEnd }));
Assert.That(second.Select(r => r.Envelope.Uri),
Is.EqualTo(new[] { NetworkBattleUri.TurnStart, NetworkBattleUri.TurnEnd }));
Assert.That(s.Phase, Is.EqualTo(BattleSessionPhase.AfterReady));
}
[Test]
public void Retire_PushesBattleFinishNoContest_TransitionsToTerminal()
{