acdream/tests/AcDream.Core.Net.Tests
Erik e395861053 test(net): N0 fix-up - CheckState gate, bundle coalescing, two-phase terminate
Addresses the N0 review findings against commit 7e9134b4. Test-only: no
production code changes.

F1 (blocking) - model Session.CheckState (Session.cs:93-110). A three-value
AceSessionState (AuthLoginRequest -> AuthConnectResponse -> AuthConnected)
advances on SendConnectRequest (AuthenticationHandler.cs:127, :232) and on the
accepted ConnectResponse (NetworkManager.cs:77). CheckState runs as the first
statement of Receive after TryParse - ahead of the ConnectResponse route and
ahead of VerifyCRC - so a LoginRequest out of state, a replayed
ConnectResponse, or any of AckSequence|TimeSync|EchoRequest|Flow during
AuthLoginRequest is dropped at zero keystream cost (ACE's PacketHeader.HasFlag
is ANY-of, PacketHeader.cs:70). New StateDropCount counter.

F2 - implement SendBundle faithfully (NetworkSession.cs:808-919). One
NetworkBundle per GameMessageGroup (NetworkBundle.cs:6-63), swapped out and
sent in ascending group order; the InvalidQueue bundle carries the ack /
TimeSync / EchoResponse optional headers. As many same-bundle fragments as fit
the 464-byte body budget now travel in ONE packet - one sequence, one keystream
word - and a message whose remaining data fills a packet splits across packets
with Count>1 fragments (:846-854, :874-888) via a port of ACE's server-side
MessageFragment (MessageFragment.cs:10-103). The old "one packet per message"
shortcut and its incorrect rationale are gone.

F3 - model the two-phase termination. Terminate arms PendingTermination with
the 2 s window (Session.cs:281-298, SessionTerminationDetails.cs:12); inbound
and outbound keep running through it (Session.cs:124-133), then the pump
completes the session work and releases the network resources
(NetworkManager.cs:366-369 -> Session.cs:300-334 -> NetworkSession.cs:958-974).
IsTerminated now means "termination armed"; IsReleased is the point of no
return.

F4 - port ACE's MessageBuffer exactly (MessageBuffer.cs:7-54): a List, not an
index-addressed array. An assembled stream under 4 bytes returns null and is
dropped WITHOUT advancing the fragment gate (:49-50 + NetworkSession.cs:504-506
removing the buffer either way), and a later fragment claiming a larger
Count/Index for the same sequence completes the message instead of throwing.

F5 - the C2S parse path now characterizes ACE: fragment parsing uses ACE's
complete validation (16 <= Size <= 464, ClientPacketFragment.cs:12-24) with no
Count==0 / Index>=Count rejection and with ReadBytes' short-read tolerance,
instead of inheriting acdream's stricter production layout check. The one
remaining strictness we inherit - the 1024-id cap on retransmit lists - is
documented as unreachable (ACE reads into a 1024-byte buffer, so a C2S datagram
can carry at most 250 ids).

F6 - class doc now states that C2S CRC verification reuses acdream's own
PacketHeaderOptional hashing, so the double is NOT an independent oracle on
optional-header wire layout, and names the two known asymmetries (ACE has no
inbound ConnectRequest parse; ACE hashes-but-does-not-advance on
LoginRequest / WorldLoginRequest / ConnectResponse).

F7 - hardened three weak tests: the NAK rate limit is probed at 0.9 s and at
exactly 1.0 s (both closed) before 1.1 s opens it; the session timeout is
probed at exactly 60 s after fixing the model's `>` to ACE's `>=`
(Session.cs:140); the cache prune pins that an entry exactly 120 s old survives
(:258 is strictly greater).

F9 - campaign doc section 9 ledger: N0 row marked complete.

Nine new tests; 687 Core.Net tests green in Release.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-29 11:42:36 +02:00
..
Cryptography feat(net): PacketHeader + PacketHeaderFlags + Hash32 checksum (Phase 4.2) 2026-04-11 14:17:37 +02:00
Messages fix(net): xpSpent is a dword on the wire, and we were sending eight bytes 2026-07-29 01:59:47 +02:00
Packets test(net): pin the transport flag word against ACE, all twenty-three bits 2026-07-29 01:54:56 +02:00
Transport test(net): N0 fix-up - CheckState gate, bundle coalescing, two-phase terminate 2026-07-29 11:42:36 +02:00
AcDream.Core.Net.Tests.csproj feat(net): AcDream.Core.Net scaffold + ISAAC keystream (Phase 4.1) 2026-04-11 14:14:28 +02:00
CombatStateWiringTests.cs feat(inventory): port retail weapon switching 2026-07-12 23:06:31 +02:00
GameEventWiringTests.cs fix #234: port retail appraisal floaty and inscriptions 2026-07-23 12:12:57 +02:00
LiveHandshakeTests.cs fix(net): conform character entry and session shutdown 2026-07-21 10:33:03 +02:00
NetClientTests.cs perf(net): own one pooled async receive 2026-07-25 05:50:18 +02:00
ObjectTableWiringTests.cs fix(ui): preserve retail item titles and spacing 2026-07-24 05:21:01 +02:00
PlayerDescriptionParserTests.cs feat: port retail magic lifecycle and retained spell UI 2026-07-15 10:55:22 +02:00
PrivateUpdateVitalTests.cs feat(player): #5 PlayerDescription parser — Stam/Mana via attribute block 2026-04-25 16:42:24 +02:00
SubscriptionSetTests.cs refactor(net): own live session composition 2026-07-22 10:36:06 +02:00
WorldSessionChatTests.cs feat(chat): route retail lifestone commands 2026-07-13 11:43:19 +02:00
WorldSessionCombatTests.cs feat(ui): finish retail toolbar controls 2026-07-11 12:11:53 +02:00
WorldSessionConstructionTests.cs perf(net): own one pooled async receive 2026-07-25 05:50:18 +02:00
WorldSessionInboundBudgetTests.cs fix(net): timeslice WorldSession.Tick inbound drain (#2 flood) 2026-06-22 15:39:50 +02:00
WorldSessionInventoryActionTests.cs fix #234: port retail appraisal floaty and inscriptions 2026-07-23 12:12:57 +02:00
WorldSessionLinkStatusTests.cs feat(ui): share indicator detail panels 2026-07-17 10:27:41 +02:00
WorldSessionNegotiationShutdownTests.cs fix(net): conform character entry and session shutdown 2026-07-21 10:33:03 +02:00
WorldSessionNetReceiveLoopResilienceTests.cs perf(net): own one pooled async receive 2026-07-25 05:50:18 +02:00
WorldSessionRadarTests.cs fix(ui): preserve retail item titles and spacing 2026-07-24 05:21:01 +02:00
WorldSessionShutdownTests.cs fix(net): conform character entry and session shutdown 2026-07-21 10:33:03 +02:00
WorldSessionWiringOwnershipTests.cs refactor(net): own live session routing 2026-07-21 11:17:09 +02:00