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 <noreply@anthropic.com>
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user