Skip to content

Commit

Permalink
fix: Distributed Authority codec tests not using message version (#3109)
Browse files Browse the repository at this point in the history
* fix

Fix issue where the CodecTestHooks was not serializing the message using the current message version.

* update

also updating the test project to use the release version of Unity 6

* fix

When sending, always use the message version.
  • Loading branch information
NoelStephensUnity authored Oct 22, 2024
1 parent a115c83 commit c696b58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,14 @@ public IEnumerator NamedMessage()
[UnityTest]
public IEnumerator NetworkVariableDelta()
{
var component = Client.LocalClient.PlayerObject.GetComponent<TestNetworkComponent>();
var message = new NetworkVariableDeltaMessage
{
NetworkObjectId = 0,
NetworkBehaviourIndex = 1,
DeliveryMappedNetworkVariableIndex = new HashSet<int> { 2, 3, 4 },
NetworkObjectId = Client.LocalClient.PlayerObject.NetworkObjectId,
NetworkBehaviourIndex = component.NetworkBehaviourId,
DeliveryMappedNetworkVariableIndex = new HashSet<int> { 0, 1 },
TargetClientId = 5,
NetworkBehaviour = Client.LocalClient.PlayerObject.GetComponent<TestNetworkComponent>(),
NetworkBehaviour = component,
};

yield return SendMessage(ref message);
Expand Down Expand Up @@ -569,7 +570,7 @@ public IEnumerator SceneEventMessageObjectSceneChanged()

private IEnumerator SendMessage<T>(ref T message) where T : INetworkMessage
{
Client.MessageManager.SetVersion(k_ClientId, XXHash.Hash32(typeof(T).FullName), 0);
Client.MessageManager.SetVersion(k_ClientId, XXHash.Hash32(typeof(T).FullName), message.Version);

var clientIds = new NativeArray<ulong>(1, Allocator.Temp);
clientIds[0] = k_ClientId;
Expand Down Expand Up @@ -625,7 +626,8 @@ public void OnBeforeSendMessage<T>(ulong clientId, ref T message, NetworkDeliver
}

var writer = new FastBufferWriter(1024, Allocator.Temp);
message.Serialize(writer, 0);
// Serialize the message using the known message version
message.Serialize(writer, message.Version);

var testName = TestContext.CurrentContext.Test.Name;
if (!m_ExpectedMessages.ContainsKey(testName))
Expand Down
4 changes: 2 additions & 2 deletions testproject/ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
m_EditorVersion: 6000.0.10f1
m_EditorVersionWithRevision: 6000.0.10f1 (413673acabac)
m_EditorVersion: 6000.0.23f1
m_EditorVersionWithRevision: 6000.0.23f1 (1c4764c07fb4)

0 comments on commit c696b58

Please sign in to comment.