From 4bc1c3eb203c05812df75028b978da398ab5ed14 Mon Sep 17 00:00:00 2001 From: vis2k Date: Tue, 3 Mar 2020 13:19:09 +0100 Subject: [PATCH] NetworkIdentityTests HandleEvent tests invalid component index / function hash too --- Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs b/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs index 473d1c376..82a8327a8 100644 --- a/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs +++ b/Assets/Mirror/Tests/Editor/NetworkIdentityTests.cs @@ -1314,6 +1314,18 @@ public void HandleSyncEvent() identity.HandleSyncEvent(componentIndex, functionHash, payload); Assert.That(comp0.called, Is.EqualTo(1)); + // try wrong component index. syncevent shouldn't be called again. + LogAssert.ignoreFailingMessages = true; // warning is expected + identity.HandleSyncEvent(1, functionHash, payload); + LogAssert.ignoreFailingMessages = false; + Assert.That(comp0.called, Is.EqualTo(1)); + + // try wrong function hash. syncevent shouldn't be called again. + LogAssert.ignoreFailingMessages = true; // warning is expected + identity.HandleSyncEvent(0, functionHash+1, payload); + LogAssert.ignoreFailingMessages = false; + Assert.That(comp0.called, Is.EqualTo(1)); + // clean up NetworkIdentity.spawned.Clear(); NetworkBehaviour.ClearDelegates();