Content changes for engine state-handling & PVS PR (#9273)

This commit is contained in:
Leon Friedrich
2022-08-21 05:38:20 +12:00
committed by GitHub
parent 5d74ac3954
commit 25093f5146
7 changed files with 32 additions and 26 deletions

View File

@@ -6,8 +6,11 @@ using System.Threading.Tasks;
using NUnit.Framework;
using Robust.Client.GameObjects;
using Robust.Client.GameStates;
using Robust.Client.Timing;
using Robust.Server.GameStates;
using Robust.Server.Player;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.IoC;
@@ -35,7 +38,7 @@ namespace Content.IntegrationTests.Tests.Networking
[Test]
public async Task Test()
{
await using var pairTracker = await PoolManager.GetServerClient(new (){Fresh = true, DisableInterpolate = true, DummyTicker = true});
await using var pairTracker = await PoolManager.GetServerClient(new (){Fresh = true, DummyTicker = true});
var server = pairTracker.Pair.Server;
var client = pairTracker.Pair.Client;
@@ -45,8 +48,12 @@ namespace Content.IntegrationTests.Tests.Networking
var sEntityManager = server.ResolveDependency<IEntityManager>();
var cEntityManager = client.ResolveDependency<IEntityManager>();
var sGameTiming = server.ResolveDependency<IGameTiming>();
var cGameTiming = client.ResolveDependency<IGameTiming>();
var cGameTiming = client.ResolveDependency<IClientGameTiming>();
var cGameStateManager = client.ResolveDependency<IClientGameStateManager>();
var cfg = client.ResolveDependency<IConfigurationManager>();
var log = cfg.GetCVar(CVars.NetLogging);
//cfg.SetCVar(CVars.NetLogging, true);
EntityUid serverEnt = default;
PredictionTestComponent serverComponent = default!;
@@ -72,14 +79,12 @@ namespace Content.IntegrationTests.Tests.Networking
// Run some ticks so that
await PoolManager.RunTicksSync(pairTracker.Pair, 3);
// Due to technical things with the game state processor it has an extra state in the buffer here.
// This burns through it real quick, but I'm not sure it should be there?
// Under normal operation (read: not integration test) this gets corrected for via tick time adjustment,
// so it's probably not an issue?
await client.WaitRunTicks(1);
// Check client buffer is full
Assert.That(cGameStateManager.CurrentBufferSize, Is.EqualTo(cGameStateManager.TargetBufferSize));
// 2 is target buffer size.
Assert.That(cGameStateManager.CurrentBufferSize, Is.EqualTo(2));
// This isn't required anymore, but the test had this for the sake of "technical things", and I cbf shifting
// all the tick times over. So it stays.
await client.WaitRunTicks(1);
await client.WaitPost(() =>
{
@@ -97,7 +102,7 @@ namespace Content.IntegrationTests.Tests.Networking
// Client last ran tick 15 meaning it's ahead of the last server tick it processed (12)
Assert.That(cGameTiming.CurTick, Is.EqualTo(new GameTick(16)));
Assert.That(cGameStateManager.CurServerTick, Is.EqualTo(new GameTick(12)));
Assert.That(cGameTiming.LastProcessedTick, Is.EqualTo(new GameTick(12)));
// *** I am using block scopes to visually distinguish these sections of the test to make it more readable.
@@ -173,7 +178,7 @@ namespace Content.IntegrationTests.Tests.Networking
// Assert timing is still correct, should be but it's a good reference for the rest of the test.
Assert.That(sGameTiming.CurTick, Is.EqualTo(new GameTick(18)));
Assert.That(cGameTiming.CurTick, Is.EqualTo(new GameTick(20)));
Assert.That(cGameStateManager.CurServerTick, Is.EqualTo(new GameTick(16)));
Assert.That(cGameTiming.LastProcessedTick, Is.EqualTo(new GameTick(16)));
{
// Send event to server to change flag again, this time to disable it..
@@ -244,7 +249,7 @@ namespace Content.IntegrationTests.Tests.Networking
// Assert timing is still correct.
Assert.That(sGameTiming.CurTick, Is.EqualTo(new GameTick(22)));
Assert.That(cGameTiming.CurTick, Is.EqualTo(new GameTick(24)));
Assert.That(cGameStateManager.CurServerTick, Is.EqualTo(new GameTick(20)));
Assert.That(cGameTiming.LastProcessedTick, Is.EqualTo(new GameTick(20)));
{
// Send first event to disable the flag (reminder: it never got accepted by the server).
@@ -359,6 +364,8 @@ namespace Content.IntegrationTests.Tests.Networking
Assert.That(clientComponent.Foo, Is.True);
}
}
cfg.SetCVar(CVars.NetLogging, log);
await pairTracker.CleanReturnAsync();
}