acdream/tests/AcDream.Core.Net.Tests/Messages/CharacterLogOffTests.cs
Erik 68578fa5fa fix(net): honor retail graceful logout handshake
Send the active character id, drain until the authoritative server confirmation, then emit retail's zero-sequence connection disconnect with the negotiated receiver iteration. The connected gate now waits for ACE to remove the exact UDP session before reconnecting, eliminating fixed-delay races.
2026-07-20 23:31:23 +02:00

36 lines
1 KiB
C#

using System.Buffers.Binary;
using AcDream.Core.Net.Messages;
namespace AcDream.Core.Net.Tests.Messages;
public sealed class CharacterLogOffTests
{
[Fact]
public void BuildRequestBody_MatchesRetailOpcodeThenCharacterId()
{
byte[] body = CharacterLogOff.BuildRequestBody(0x5000000Au);
Assert.Equal(8, body.Length);
Assert.Equal(
CharacterLogOff.Opcode,
BinaryPrimitives.ReadUInt32LittleEndian(body));
Assert.Equal(
0x5000000Au,
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(4)));
}
[Fact]
public void IsConfirmation_AcceptsServerOpcodeOnlyBody()
{
byte[] body = BitConverter.GetBytes(CharacterLogOff.Opcode);
Assert.True(CharacterLogOff.IsConfirmation(body));
}
[Fact]
public void IsConfirmation_RejectsTruncatedOrDifferentMessage()
{
Assert.False(CharacterLogOff.IsConfirmation([0x53, 0xF6, 0x00]));
Assert.False(CharacterLogOff.IsConfirmation(BitConverter.GetBytes(0xF654u)));
}
}