forked from space-syndicate/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some tests and fix some miscellaneous bugs (#22836)
* Add some tests and fix some bugs * Add more helper methods * remove submodule * fix merge * also fix DirtyAll() * poke
- Loading branch information
Showing
14 changed files
with
292 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
Content.IntegrationTests/Tests/Networking/PvsCommandTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using Robust.Shared.GameObjects; | ||
using Robust.Shared.Map.Components; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.IntegrationTests.Tests.Networking; | ||
|
||
[TestFixture] | ||
public sealed class PvsCommandTest | ||
{ | ||
public static EntProtoId TestEnt = "MobHuman"; | ||
|
||
[Test] | ||
public async Task TestPvsCommands() | ||
{ | ||
await using var pair = await PoolManager.GetServerClient(new PoolSettings { Connected = true, DummyTicker = false}); | ||
var (server, client) = pair; | ||
await pair.RunTicksSync(5); | ||
|
||
// Spawn a complex entity. | ||
EntityUid entity = default; | ||
await server.WaitPost(() => entity = server.EntMan.Spawn(TestEnt)); | ||
await pair.RunTicksSync(5); | ||
|
||
// Check that the client has a variety pf entities. | ||
Assert.That(client.EntMan.EntityCount, Is.GreaterThan(0)); | ||
Assert.That(client.EntMan.Count<MapComponent>, Is.GreaterThan(0)); | ||
Assert.That(client.EntMan.Count<MapGridComponent>, Is.GreaterThan(0)); | ||
|
||
var meta = client.MetaData(pair.ToClientUid(entity)); | ||
var lastApplied = meta.LastStateApplied; | ||
|
||
// Dirty all entities | ||
await server.ExecuteCommand("dirty"); | ||
await pair.RunTicksSync(5); | ||
Assert.That(meta.LastStateApplied, Is.GreaterThan(lastApplied)); | ||
await pair.RunTicksSync(5); | ||
|
||
// Do a client-side full state reset | ||
await client.ExecuteCommand("resetallents"); | ||
await pair.RunTicksSync(5); | ||
|
||
// Request a full server state. | ||
lastApplied = meta.LastStateApplied; | ||
await client.ExecuteCommand("fullstatereset"); | ||
await pair.RunTicksSync(10); | ||
Assert.That(meta.LastStateApplied, Is.GreaterThan(lastApplied)); | ||
|
||
await server.WaitPost(() => server.EntMan.DeleteEntity(entity)); | ||
await pair.CleanReturnAsync(); | ||
} | ||
} |
Oops, something went wrong.