From ff8e4abea85a0a8d38aeb67faa79d9c7c3c5ae7b Mon Sep 17 00:00:00 2001 From: gamer147 Date: Mon, 1 Jun 2026 15:04:21 -0400 Subject: [PATCH] test(battle-node): integration test drives two opponent-turn cycles End-to-end through the real WS pump: after Ready, the test sends two consecutive TurnEnd msgs and asserts the server pushes TurnStart+TurnEnd for each. Exercises OutboundSequencer's playSeq assignment across multiple cycles. --- .../Integration/BattleNodeFlowTests.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/SVSim.UnitTests/BattleNode/Integration/BattleNodeFlowTests.cs b/SVSim.UnitTests/BattleNode/Integration/BattleNodeFlowTests.cs index 46100f8..5192f9c 100644 --- a/SVSim.UnitTests/BattleNode/Integration/BattleNodeFlowTests.cs +++ b/SVSim.UnitTests/BattleNode/Integration/BattleNodeFlowTests.cs @@ -16,10 +16,11 @@ namespace SVSim.UnitTests.BattleNode.Integration; public class BattleNodeFlowTests { /// - /// End-to-end smoke for the v1 scripted lifecycle. Boots the EmulatedEntrypoint via + /// End-to-end smoke for the v1.1 scripted lifecycle. Boots the EmulatedEntrypoint via /// SVSimTestFactory, mints a battle through IMatchingBridge with a fixture MatchContext, /// opens a raw Socket.IO v2 client against the in-process TestServer, and drives - /// InitNetwork → Loaded → Swap, asserting the right scripted frames come back in order. + /// InitNetwork → Loaded → Swap → TurnEnd × 2, asserting the right scripted frames come + /// back in order including the two-cycle opponent-turn loop. /// [Test] [Timeout(30000)] @@ -55,6 +56,17 @@ public class BattleNodeFlowTests body: new Dictionary { ["idxList"] = new List() }), key, ct); Assert.That((await client.ReceiveSynchronizeAsync(ct)).Uri, Is.EqualTo(NetworkBattleUri.Swap)); Assert.That((await client.ReceiveSynchronizeAsync(ct)).Uri, Is.EqualTo(NetworkBattleUri.Ready)); + + // --- v1.1 opponent turn loop: drive two consecutive cycles --- + // Cycle 1: player ends turn -> server pushes opponent TurnStart + TurnEnd. + await client.SendMsgAsync(MakeEnvelope(NetworkBattleUri.TurnEnd, pubSeq: 5), key, ct); + Assert.That((await client.ReceiveSynchronizeAsync(ct)).Uri, Is.EqualTo(NetworkBattleUri.TurnStart)); + Assert.That((await client.ReceiveSynchronizeAsync(ct)).Uri, Is.EqualTo(NetworkBattleUri.TurnEnd)); + + // Cycle 2: same burst again -- session phase reset to AfterReady, so the next TurnEnd matches. + await client.SendMsgAsync(MakeEnvelope(NetworkBattleUri.TurnEnd, pubSeq: 6), key, ct); + Assert.That((await client.ReceiveSynchronizeAsync(ct)).Uri, Is.EqualTo(NetworkBattleUri.TurnStart)); + Assert.That((await client.ReceiveSynchronizeAsync(ct)).Uri, Is.EqualTo(NetworkBattleUri.TurnEnd)); } private static MsgEnvelope MakeEnvelope(NetworkBattleUri uri, long pubSeq, Dictionary? body = null) =>