mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
NetworkIdentityTests HandleRpc tests invalid component index / function hash too
This commit is contained in:
parent
b9dab2ca7a
commit
bbcc3599ef
@ -1268,10 +1268,21 @@ public void HandleRpc()
|
|||||||
NetworkIdentity.spawned[identity.netId] = identity;
|
NetworkIdentity.spawned[identity.netId] = identity;
|
||||||
|
|
||||||
// call HandleRpc and check if the rpc was called in the component
|
// call HandleRpc and check if the rpc was called in the component
|
||||||
int componentIndex = 0;
|
|
||||||
int functionHash = NetworkBehaviour.GetMethodHash(typeof(RpcTestNetworkBehaviour), nameof(RpcTestNetworkBehaviour.RpcGenerated));
|
int functionHash = NetworkBehaviour.GetMethodHash(typeof(RpcTestNetworkBehaviour), nameof(RpcTestNetworkBehaviour.RpcGenerated));
|
||||||
NetworkReader payload = new NetworkReader(new byte[0]);
|
NetworkReader payload = new NetworkReader(new byte[0]);
|
||||||
identity.HandleRPC(componentIndex, functionHash, payload);
|
identity.HandleRPC(0, functionHash, payload);
|
||||||
|
Assert.That(comp0.called, Is.EqualTo(1));
|
||||||
|
|
||||||
|
// try wrong component index. rpc shouldn't be called again.
|
||||||
|
LogAssert.ignoreFailingMessages = true; // warning is expected
|
||||||
|
identity.HandleRPC(1, functionHash, payload);
|
||||||
|
LogAssert.ignoreFailingMessages = false;
|
||||||
|
Assert.That(comp0.called, Is.EqualTo(1));
|
||||||
|
|
||||||
|
// try wrong function hash. rpc shouldn't be called again.
|
||||||
|
LogAssert.ignoreFailingMessages = true; // warning is expected
|
||||||
|
identity.HandleRPC(0, functionHash+1, payload);
|
||||||
|
LogAssert.ignoreFailingMessages = false;
|
||||||
Assert.That(comp0.called, Is.EqualTo(1));
|
Assert.That(comp0.called, Is.EqualTo(1));
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
|
Loading…
Reference in New Issue
Block a user