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.
This commit is contained in:
gamer147
2026-06-01 15:04:21 -04:00
parent decdef29cf
commit ff8e4abea8

View File

@@ -16,10 +16,11 @@ namespace SVSim.UnitTests.BattleNode.Integration;
public class BattleNodeFlowTests
{
/// <summary>
/// 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.
/// </summary>
[Test]
[Timeout(30000)]
@@ -55,6 +56,17 @@ public class BattleNodeFlowTests
body: new Dictionary<string, object?> { ["idxList"] = new List<object?>() }), 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<string, object?>? body = null) =>