test(battle-node): integration test expects three frames per cycle
End-to-end exercises the v1.2 burst: each TurnEnd from the client now produces TurnStart + TurnEnd + Judge through the real WS pump.
This commit is contained in:
@@ -16,11 +16,12 @@ namespace SVSim.UnitTests.BattleNode.Integration;
|
|||||||
public class BattleNodeFlowTests
|
public class BattleNodeFlowTests
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// End-to-end smoke for the v1.1 scripted lifecycle. Boots the EmulatedEntrypoint via
|
/// End-to-end smoke for the v1.2 scripted lifecycle. Boots the EmulatedEntrypoint via
|
||||||
/// SVSimTestFactory, mints a battle through IMatchingBridge with a fixture MatchContext,
|
/// SVSimTestFactory, mints a battle through IMatchingBridge with a fixture MatchContext,
|
||||||
/// opens a raw Socket.IO v2 client against the in-process TestServer, and drives
|
/// opens a raw Socket.IO v2 client against the in-process TestServer, and drives
|
||||||
/// InitNetwork → Loaded → Swap → TurnEnd × 2, asserting the right scripted frames come
|
/// InitNetwork → Loaded → Swap → TurnEnd × 2, asserting the right scripted frames come
|
||||||
/// back in order including the two-cycle opponent-turn loop.
|
/// back in order including the two-cycle three-frame opponent-turn loop (TurnStart +
|
||||||
|
/// TurnEnd + Judge per cycle).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
[Timeout(30000)]
|
[Timeout(30000)]
|
||||||
@@ -57,16 +58,18 @@ public class BattleNodeFlowTests
|
|||||||
Assert.That((await client.ReceiveSynchronizeAsync(ct)).Uri, Is.EqualTo(NetworkBattleUri.Swap));
|
Assert.That((await client.ReceiveSynchronizeAsync(ct)).Uri, Is.EqualTo(NetworkBattleUri.Swap));
|
||||||
Assert.That((await client.ReceiveSynchronizeAsync(ct)).Uri, Is.EqualTo(NetworkBattleUri.Ready));
|
Assert.That((await client.ReceiveSynchronizeAsync(ct)).Uri, Is.EqualTo(NetworkBattleUri.Ready));
|
||||||
|
|
||||||
// --- v1.1 opponent turn loop: drive two consecutive cycles ---
|
// --- v1.2 opponent turn loop: drive two consecutive cycles ---
|
||||||
// Cycle 1: player ends turn -> server pushes opponent TurnStart + TurnEnd.
|
// Cycle 1: player ends turn -> server pushes opponent TurnStart + TurnEnd + Judge.
|
||||||
await client.SendMsgAsync(MakeEnvelope(NetworkBattleUri.TurnEnd, pubSeq: 5), key, ct);
|
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.TurnStart));
|
||||||
Assert.That((await client.ReceiveSynchronizeAsync(ct)).Uri, Is.EqualTo(NetworkBattleUri.TurnEnd));
|
Assert.That((await client.ReceiveSynchronizeAsync(ct)).Uri, Is.EqualTo(NetworkBattleUri.TurnEnd));
|
||||||
|
Assert.That((await client.ReceiveSynchronizeAsync(ct)).Uri, Is.EqualTo(NetworkBattleUri.Judge));
|
||||||
|
|
||||||
// Cycle 2: same burst again -- session phase reset to AfterReady, so the next TurnEnd matches.
|
// 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);
|
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.TurnStart));
|
||||||
Assert.That((await client.ReceiveSynchronizeAsync(ct)).Uri, Is.EqualTo(NetworkBattleUri.TurnEnd));
|
Assert.That((await client.ReceiveSynchronizeAsync(ct)).Uri, Is.EqualTo(NetworkBattleUri.TurnEnd));
|
||||||
|
Assert.That((await client.ReceiveSynchronizeAsync(ct)).Uri, Is.EqualTo(NetworkBattleUri.Judge));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MsgEnvelope MakeEnvelope(NetworkBattleUri uri, long pubSeq, Dictionary<string, object?>? body = null) =>
|
private static MsgEnvelope MakeEnvelope(NetworkBattleUri uri, long pubSeq, Dictionary<string, object?>? body = null) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user