Skip to content

Commit 71cfa42

Browse files
test
Updating the NetworkRigidbodyTest to do a 2nd spawn pass that swaps the session owner and non-session owner clients to validate it works when a non-session authority client is the spawn authority.
1 parent f6e522c commit 71cfa42

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

com.unity.netcode.gameobjects/Tests/Runtime/Physics/NetworkRigidbodyTest.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,29 @@ public IEnumerator TestRigidbodyKinematicEnableDisable()
9696
{
9797
m_CurrentConfiguration = configuration;
9898
ApplyCurrentTestConfiguration();
99+
100+
// Host, Server, DAHost/Session-owner are spawn authority
99101
yield return RunTestConfiguration();
102+
103+
// When using distributed authority, swap the session owner with
104+
// the non-session owner client as being the spawn authority.
105+
if (m_DistributedAuthority)
106+
{
107+
yield return RunTestConfiguration(true);
108+
}
100109
}
101110
}
102111

103112
/// <summary>
104113
/// Validates the current applied test configuration.
105114
/// </summary>
106-
private IEnumerator RunTestConfiguration()
115+
private IEnumerator RunTestConfiguration(bool swapAuthority = false)
107116
{
108-
var authority = GetAuthorityNetworkManager();
109-
var nonAuthority = GetNonAuthorityNetworkManager();
117+
// The authority is the "spawn authority".
118+
// Distributed authority runs this a second time with a non-session owner client being the
119+
// spawn authority to validate that scenario works correctly.
120+
var authority = !swapAuthority ? GetAuthorityNetworkManager() : GetNonAuthorityNetworkManager();
121+
var nonAuthority = !swapAuthority ? GetNonAuthorityNetworkManager() : GetAuthorityNetworkManager();
110122

111123
// Spawn instances of both the 3D and 2D prefabs configured for the current test.
112124
m_3DAuthorityInstance = SpawnObject(m_RigidbodyPrefab, authority).GetComponent<NetworkObject>();

0 commit comments

Comments
 (0)