Skip to content

chore: remove ClientNetworkVariable #1167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using NUnit.Framework;
using Unity.Collections;


namespace Unity.Netcode.RuntimeTests
{
public struct FixedString32Struct : INetworkSerializable
Expand Down Expand Up @@ -43,13 +42,9 @@ public void NetworkSerialize(NetworkSerializer serializer)
serializer.Serialize(ref SomeBool);
}
}

public class NetworkVariableTest : NetworkBehaviour
{
public readonly ClientNetworkVariable<int> ClientVar = new ClientNetworkVariable<int>();

public readonly ClientNetworkVariable<int> ClientVarPrivate =
new ClientNetworkVariable<int>(NetworkVariableReadPermission.OwnerOnly);

public readonly NetworkVariable<int> TheScalar = new NetworkVariable<int>();
public readonly NetworkList<int> TheList = new NetworkList<int>();
public readonly NetworkSet<int> TheSet = new NetworkSet<int>();
Expand Down Expand Up @@ -232,38 +227,6 @@ public void ClientWritePermissionTest([Values(true, false)] bool useHost)
Assert.Throws<InvalidOperationException>(() => m_Player1OnClient1.TheScalar.Value = k_TestVal1);
}

[Test]
public void ServerWritePermissionTest([Values(true, false)] bool useHost)
{
m_TestWithHost = useHost;

// server must not be allowed to write to a client auth variable
Assert.Throws<InvalidOperationException>(() => m_Player1OnServer.ClientVar.Value = k_TestVal1);
}

[UnityTest]
public IEnumerator ClientTest([Values(true, false)] bool useHost)
{
m_TestWithHost = useHost;

yield return MultiInstanceHelpers.RunAndWaitForCondition(
() =>
{
m_Player1OnClient1.ClientVar.Value = k_TestVal2;
m_Player2OnClient2.ClientVar.Value = k_TestVal3;
},
() =>
{
// the client's values should win on the objects it owns
return
m_Player1OnServer.ClientVar.Value == k_TestVal2 &&
m_Player2OnServer.ClientVar.Value == k_TestVal3 &&
m_Player1OnClient1.ClientVar.Value == k_TestVal2 &&
m_Player2OnClient2.ClientVar.Value == k_TestVal3;
}
);
}

[UnityTest]
public IEnumerator FixedString32StructTest([Values(true, false)] bool useHost)
{
Expand All @@ -289,33 +252,6 @@ public IEnumerator FixedString32StructTest([Values(true, false)] bool useHost)
);
}

[UnityTest]
public IEnumerator PrivateClientTest([Values(true, false)] bool useHost)
{
m_TestWithHost = useHost;

yield return MultiInstanceHelpers.RunAndWaitForCondition(
() =>
{
// we are writing to the private and public variables on player 1's object...
m_Player1OnClient1.ClientVarPrivate.Value = k_TestVal1;
m_Player1OnClient1.ClientVar.Value = k_TestVal2;
},
() =>
{
// ...and we should see the writes to the private var only on the server & the owner,
// but the public variable everywhere
return
m_Player1OnClient2.ClientVarPrivate.Value != k_TestVal1 &&
m_Player1OnClient1.ClientVarPrivate.Value == k_TestVal1 &&
m_Player1OnClient2.ClientVar.Value != k_TestVal2 &&
m_Player1OnClient1.ClientVar.Value == k_TestVal2 &&
m_Player1OnServer.ClientVarPrivate.Value == k_TestVal1 &&
m_Player1OnServer.ClientVar.Value == k_TestVal2;
}
);
}

[UnityTest]
public IEnumerator NetworkListAdd([Values(true, false)] bool useHost)
{
Expand Down