Skip to content

Commit 0b100cc

Browse files
committed
Fix tests
1 parent 53904d7 commit 0b100cc

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

com.unity.netcode.gameobjects/TestHelpers/Runtime/NetcodeIntegrationTest.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,7 @@ protected IEnumerator StartClient(NetworkManager networkManager)
757757
{
758758
// Wait for the new client to connect
759759
yield return WaitForClientsConnectedOrTimeOut();
760+
AssertOnTimeout($"{nameof(StartClient)} timed out waiting for all clients to be connected!\n {m_InternalErrorLog}");
760761

761762
OnNewClientStartedAndConnected(networkManager);
762763
if (s_GlobalTimeoutHelper.TimedOut)
@@ -839,6 +840,7 @@ protected void CreateAndStartNewClientWithTimeTravel()
839840

840841
// Wait for the new client to connect
841842
var connected = WaitForClientsConnectedOrTimeOutWithTimeTravel();
843+
AssertOnTimeout($"{nameof(CreateAndStartNewClientWithTimeTravel)} timed out waiting for all clients to be connected!\n {m_InternalErrorLog}");
842844

843845
OnNewClientStartedAndConnected(networkManager);
844846
if (!connected)
@@ -1342,6 +1344,13 @@ protected IEnumerator CoroutineShutdownAndCleanUp()
13421344
{
13431345
VerboseDebug($"Entering {nameof(ShutdownAndCleanUp)}");
13441346
// Shutdown and clean up both of our NetworkManager instances
1347+
1348+
foreach (var networkManager in m_NetworkManagers)
1349+
{
1350+
networkManager.Shutdown();
1351+
}
1352+
yield return k_DefaultTickRate;
1353+
13451354
try
13461355
{
13471356
DeRegisterSceneManagerHandler();

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ internal class NetworkObjectSpawnManyObjectsTests : NetcodeIntegrationTest
1818

1919
public NetworkObjectSpawnManyObjectsTests(NetworkTopologyTypes networkTopologyType) : base(networkTopologyType) { }
2020
// Using this component assures we will know precisely how many prefabs were spawned on the client
21-
internal class SpawnObjecTrackingComponent : NetworkBehaviour
21+
internal class SpawnObjectTrackingComponent : NetworkBehaviour
2222
{
2323
public static int SpawnedObjects;
2424
public override void OnNetworkSpawn()
2525
{
26-
if (!IsServer)
26+
if (!IsOwner)
2727
{
2828
SpawnedObjects++;
2929
}
@@ -32,13 +32,13 @@ public override void OnNetworkSpawn()
3232

3333
protected override void OnServerAndClientsCreated()
3434
{
35-
SpawnObjecTrackingComponent.SpawnedObjects = 0;
35+
SpawnObjectTrackingComponent.SpawnedObjects = 0;
3636
// create prefab
3737
var gameObject = new GameObject("TestObject");
3838
var networkObject = gameObject.AddComponent<NetworkObject>();
3939
NetcodeIntegrationTestHelpers.MakeNetworkObjectTestPrefab(networkObject);
4040
networkObject.IsSceneObject = false;
41-
gameObject.AddComponent<SpawnObjecTrackingComponent>();
41+
gameObject.AddComponent<SpawnObjectTrackingComponent>();
4242

4343
m_PrefabToSpawn = new NetworkPrefab() { Prefab = gameObject };
4444

@@ -57,20 +57,17 @@ public IEnumerator WhenManyObjectsAreSpawnedAtOnce_AllAreReceived()
5757
{
5858
NetworkObject serverObject = Object.Instantiate(m_PrefabToSpawn.Prefab).GetComponent<NetworkObject>();
5959
serverObject.NetworkManagerOwner = authority;
60+
serverObject.SpawnWithObservers = true;
6061
serverObject.Spawn();
6162
}
6263

6364
var timeSpawned = Time.realtimeSinceStartup - timeStarted;
6465
// Provide plenty of time to spawn all 1500 objects in case the CI VM is running slow
6566
var timeoutHelper = new TimeoutHelper(30);
6667
// ensure all objects are replicated
67-
yield return WaitForConditionOrTimeOut(() => SpawnObjecTrackingComponent.SpawnedObjects == k_SpawnedObjects, timeoutHelper);
68+
yield return WaitForConditionOrTimeOut(() => SpawnObjectTrackingComponent.SpawnedObjects == k_SpawnedObjects, timeoutHelper);
6869

6970
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-
// Provide one full tick for all messages to finish being processed.
72-
// DANGO-TODO: Determine if this is only when testing against Rust server (i.e. messages still pending and clients shutting down before they are dequeued)
73-
yield return s_DefaultWaitForTick;
7471
}
7572
}
7673
}

com.unity.netcode.gameobjects/Tests/Runtime/NetworkVariable/NetworkVariableTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,8 @@ private void InitializeServerAndClients(HostOrServer useHost)
473473
m_PlayerPrefab.AddComponent<ClassHavingNetworkBehaviour2>();
474474
m_PlayerPrefab.AddComponent<StructHavingNetworkBehaviour>();
475475

476-
m_DistributedAuthority = useHost == HostOrServer.DAHost;
477-
m_NetworkTopologyType = m_DistributedAuthority ? NetworkTopologyTypes.DistributedAuthority : NetworkTopologyTypes.ClientServer;
476+
m_UseHost = useHost == HostOrServer.DAHost || useHost == HostOrServer.Host;
477+
m_NetworkTopologyType = useHost == HostOrServer.DAHost ? NetworkTopologyTypes.DistributedAuthority : NetworkTopologyTypes.ClientServer;
478478

479479
m_ServerNetworkManager.NetworkConfig.EnsureNetworkVariableLengthSafety = m_EnsureLengthSafety;
480480
m_ServerNetworkManager.NetworkConfig.PlayerPrefab = m_PlayerPrefab;

0 commit comments

Comments
 (0)