fix(runtime): close Campaign LA7b review findings
This commit is contained in:
parent
0e82cbf700
commit
1b9e7e41f9
11 changed files with 700 additions and 28 deletions
|
|
@ -3,6 +3,7 @@ using System.Net;
|
|||
using System.Reflection;
|
||||
using AcDream.Core.Net.Messages;
|
||||
using AcDream.Core.Net.Packets;
|
||||
using AcDream.Core.Net.Tests.Transport;
|
||||
|
||||
namespace AcDream.Core.Net.Tests;
|
||||
|
||||
|
|
@ -91,11 +92,80 @@ public sealed class WorldSessionCharacterSelectionTests
|
|||
Assert.Equal(1u, current.SecondsGreyedOut);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImmediateEnterWorld_IgnoresNumErrorsSentinelBeforeServerReady()
|
||||
{
|
||||
var transport = new FakeAceTransport
|
||||
{
|
||||
AutoReplyServerReady = false,
|
||||
};
|
||||
using var session = new WorldSession(
|
||||
new IPEndPoint(IPAddress.Loopback, 9000),
|
||||
transport);
|
||||
int errors = 0;
|
||||
session.CharacterErrorReceived += _ => errors++;
|
||||
ConfigureSentinelThenServerReady(transport);
|
||||
|
||||
session.Connect(
|
||||
FakeAceTransport.DefaultAccountName,
|
||||
"testpassword",
|
||||
TimeSpan.FromSeconds(5));
|
||||
session.EnterWorld(0, TimeSpan.FromSeconds(5));
|
||||
|
||||
Assert.Equal(WorldSession.State.InWorld, session.CurrentState);
|
||||
Assert.Equal(0, errors);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PausedEnterWorld_IgnoresNumErrorsSentinelBeforeServerReady()
|
||||
{
|
||||
var transport = new FakeAceTransport
|
||||
{
|
||||
AutoReplyServerReady = false,
|
||||
};
|
||||
using var session = new WorldSession(
|
||||
new IPEndPoint(IPAddress.Loopback, 9000),
|
||||
transport);
|
||||
int errors = 0;
|
||||
session.CharacterErrorReceived += _ => errors++;
|
||||
ConfigureSentinelThenServerReady(transport);
|
||||
|
||||
session.Connect(
|
||||
FakeAceTransport.DefaultAccountName,
|
||||
"testpassword",
|
||||
TimeSpan.FromSeconds(5));
|
||||
session.StartCharacterSelectionReceive();
|
||||
session.EnterWorld(0, TimeSpan.FromSeconds(5));
|
||||
|
||||
Assert.Equal(WorldSession.State.InWorld, session.CurrentState);
|
||||
Assert.Equal(0, errors);
|
||||
}
|
||||
|
||||
private static WorldSession CreateSession() =>
|
||||
new(
|
||||
new IPEndPoint(IPAddress.Loopback, 9000),
|
||||
new NullTransport());
|
||||
|
||||
private static void ConfigureSentinelThenServerReady(
|
||||
FakeAceTransport transport)
|
||||
{
|
||||
transport.Model.MessageDispatched += body =>
|
||||
{
|
||||
if (BinaryPrimitives.ReadUInt32LittleEndian(body)
|
||||
!= CharacterEnterWorld.EnterWorldRequestOpcode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
transport.Model.EnqueueGameMessage(
|
||||
BuildCharacterError(CharacterError.Code.NumErrors),
|
||||
GameMessageGroup.UIQueue);
|
||||
transport.Model.EnqueueGameMessage(
|
||||
BitConverter.GetBytes(0xF7DFu),
|
||||
GameMessageGroup.UIQueue);
|
||||
};
|
||||
}
|
||||
|
||||
private static byte[] BuildRoster(uint secondsGreyedOut)
|
||||
{
|
||||
var writer = new PacketWriter(96);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue