From bca94648f707eb511c1760c1a391f8cf462d66ed Mon Sep 17 00:00:00 2001 From: gamer147 Date: Wed, 3 Jun 2026 18:21:01 -0400 Subject: [PATCH] test(battle-node): update PvpHandshakeAndGameplay to deterministic-turn translator contract The end-to-end PvP gameplay test asserted the pre-translator relay contract (A's TurnEnd broadcasts TurnEnd+Judge to both sides). Tasks 7/8 replaced that with the per-URI translator: the active player ends its turn by sending TurnEnd then Judge, the opponent receives the translated {turnState:0}/{spin:0} frames, and the sender receives nothing. Rewrote the gameplay section to drive and assert the new contract. PlayActions remains delivered to the opponent (Uri preserved, body now synthesized by PlayActionsHandler). Co-Authored-By: Claude Opus 4.8 --- .../Integration/BattleNodeFlowTests.cs | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/SVSim.UnitTests/BattleNode/Integration/BattleNodeFlowTests.cs b/SVSim.UnitTests/BattleNode/Integration/BattleNodeFlowTests.cs index acababe..83d9c40 100644 --- a/SVSim.UnitTests/BattleNode/Integration/BattleNodeFlowTests.cs +++ b/SVSim.UnitTests/BattleNode/Integration/BattleNodeFlowTests.cs @@ -220,21 +220,22 @@ public class BattleNodeFlowTests await DrivePvpHandshakeAsync(clientA, vidA, clientB, vidB, key, ct); - // Both are now AfterReady. A sends TurnEnd; both should receive TurnEnd + Judge. + // Both are now AfterReady. Deterministic-turn translator contract (per-URI, opponent- + // facing): the active player ends its turn by sending TurnEnd then Judge. The OPPONENT + // (B) receives the translated {turnState:0} TurnEnd and {spin:0} Judge; the sender (A) + // receives nothing back — it already ran the action locally. (Old behavior broadcast + // TurnEnd+Judge to both sides; that 4-route relay was replaced by the translator.) await clientA.SendMsgAsync(MakeEnvelopeWith(vidA, NetworkBattleUri.TurnEnd, pubSeq: 5), key, ct); + var bTurnEnd = await clientB.ReceiveSynchronizeAsync(ct); + Assert.That(bTurnEnd.Uri, Is.EqualTo(NetworkBattleUri.TurnEnd)); - var aFirst = await clientA.ReceiveSynchronizeAsync(ct); - var aSecond = await clientA.ReceiveSynchronizeAsync(ct); - var bFirst = await clientB.ReceiveSynchronizeAsync(ct); - var bSecond = await clientB.ReceiveSynchronizeAsync(ct); + await clientA.SendMsgAsync(MakeEnvelopeWith(vidA, NetworkBattleUri.Judge, pubSeq: 6), key, ct); + var bJudge = await clientB.ReceiveSynchronizeAsync(ct); + Assert.That(bJudge.Uri, Is.EqualTo(NetworkBattleUri.Judge)); - Assert.That(new[] { aFirst.Uri, aSecond.Uri }, - Is.EquivalentTo(new[] { NetworkBattleUri.TurnEnd, NetworkBattleUri.Judge })); - Assert.That(new[] { bFirst.Uri, bSecond.Uri }, - Is.EquivalentTo(new[] { NetworkBattleUri.TurnEnd, NetworkBattleUri.Judge })); - - // PlayActions forwarding: B sends, A receives. - await clientB.SendMsgAsync(MakeEnvelopeWith(vidB, NetworkBattleUri.PlayActions, pubSeq: 6), key, ct); + // PlayActions translation: B plays a card; A receives the opponent-facing PlayActions + // frame (Uri preserved, body synthesized by PlayActionsHandler). + await clientB.SendMsgAsync(MakeEnvelopeWith(vidB, NetworkBattleUri.PlayActions, pubSeq: 5), key, ct); var aForwarded = await clientA.ReceiveSynchronizeAsync(ct); Assert.That(aForwarded.Uri, Is.EqualTo(NetworkBattleUri.PlayActions)); }