Skip to content

Commit 3e72d79

Browse files
Test - Stability
Adjusted 3 tests that showed potential for instabilities.
1 parent 2cb2d84 commit 3e72d79

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributeObjectsTests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ private bool ValidateOwnershipTablesMatch()
161161
{
162162
foreach (var client in clients)
163163
{
164+
if (!DistributeObjectsTestHelper.DistributedObjects.ContainsKey(client))
165+
{
166+
m_ErrorLog.AppendLine($"[Client-{client}] Does not have an entry in the root of the {nameof(DistributeObjectsTestHelper.DistributedObjects)} table!");
167+
return false;
168+
}
164169
var clientOwnerTable = DistributeObjectsTestHelper.DistributedObjects[client];
165170
if (!clientOwnerTable.ContainsKey(hostClientEntry.Key))
166171
{

com.unity.netcode.gameobjects/Tests/Runtime/NetworkObject/NetworkObjectOwnershipTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ protected override void OnServerAndClientsCreated()
9292
base.OnServerAndClientsCreated();
9393
}
9494

95-
[Test]
96-
public void TestPlayerIsOwned()
95+
[UnityTest]
96+
public IEnumerator TestPlayerIsOwned()
9797
{
9898
var clientOwnedObjects = m_ClientNetworkManagers[0].SpawnManager.GetClientOwnedObjects(m_ClientNetworkManagers[0].LocalClientId);
9999

@@ -102,6 +102,7 @@ public void TestPlayerIsOwned()
102102

103103
clientPlayerObject = m_ClientNetworkManagers[0].LocalClient.OwnedObjects.Where((c) => c.IsLocalPlayer).FirstOrDefault();
104104
Assert.NotNull(clientPlayerObject, $"Client Id {m_ClientNetworkManagers[0].LocalClientId} does not have its local player marked as an owned object using local client!");
105+
yield return null;
105106
}
106107

107108
private bool AllObjectsSpawnedOnClients()

com.unity.netcode.gameobjects/Tests/Runtime/NetworkObject/NetworkObjectSpawnManyObjectsTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ public IEnumerator WhenManyObjectsAreSpawnedAtOnce_AllAreReceived()
6767
yield return WaitForConditionOrTimeOut(() => SpawnObjecTrackingComponent.SpawnedObjects == k_SpawnedObjects, timeoutHelper);
6868

6969
AssertOnTimeout($"Timed out waiting for the client to spawn {k_SpawnedObjects} objects! Time to spawn: {timeSpawned} | Time to timeout: {timeStarted - Time.realtimeSinceStartup}", timeoutHelper);
70+
71+
yield return s_DefaultWaitForTick;
7072
}
7173
}
7274
}

0 commit comments

Comments
 (0)