Skip to content

test: generate canonical bools in NetworkVariable serialization tests - #4198

Open
NoelStephensUnity wants to merge 2 commits into
develop-3.x.xfrom
fix/test-canonical-random-bools
Open

NoelStephensUnity wants to merge 2 commits into
develop-3.x.xfrom
fix/test-canonical-random-bools

Conversation

@NoelStephensUnity

@NoelStephensUnity NoelStephensUnity commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Purpose of this PR

Fixes 4 NetworkVariableTests failures on the mac arm64 IL2CPP nightly, where List<bool> and NativeHashMap<K, bool> comparisons fail even though both sides print identical contents.

RandGenBytes<bool> filled each bool with a random byte, so most values were neither 0 nor 1. Those print True but can compare unequal under IL2CPP on ARM64. The new RandGenBool returns only false or true, and replaces every RandGenBytes<bool> call site plus the NativeArray<bool> lambda from #4194, so all bool cases share one generator.

Jira ticket

None.

Documentation

  • No documentation changes or additions were necessary.

Testing & QA (How your changes can be verified during release Playtest)

Functional Testing

Automated tests:

  • Covered by existing automated tests

Test-only change; the mac arm64 IL2CPP nightly is the confirming run.

Up-port

Not needed; this targets develop-3.x.x.

Backports

develop-2.0.0 uses the same generator (13 call sites); a separate PR if it shows the same failure there.

RandGenBytes<bool> filled each bool with a random byte, so most values were
neither 0 nor 1. On mac arm64 IL2CPP the List<bool> and NativeHashMap<K, bool>
cases then failed with both sides printing identical all-True contents.
RandGenBool returns only false or true.
@NoelStephensUnity
NoelStephensUnity requested a review from a team as a code owner October 19, 2026 17:18

@u-pr u-pr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Harness Review

Needs changes

The change consistently replaces raw-byte boolean generation with canonical values across the managed and native collection serialization tests.

Reviewed commit 9d1ac26

🤖 Helpful? 👍/👎

else if (testType == typeof(bool))
{
(var original, var original2, var changed, var changed2) = GetLists(RandGenBytes<bool>);
(var original, var original2, var changed, var changed2) = GetLists(RandGenBool);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1

The boolean list tests can now fail intermittently even when serialization is correct. GetLists allows changed2Adds == 0 and overwrites randomly selected positions with freshly generated booleans. Those overwrites can all preserve the existing values, leaving original2 and changed2 equal. TestList then unconditionally calls AssertListsDoNotMatch after assigning changedValue. GetNativeLists and TestValueTypeNativeList have the same issue. Guarantee that the final changed2 differs from original2 in both list generators.

🤖 Helpful? 👍/👎

@codecov-github-com

codecov-github-com Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

@@              Coverage Diff               @@
##           develop-3.x.x    #4198   +/-   ##
==============================================
  Coverage          76.03%   76.03%           
==============================================
  Files                159      159           
  Lines              27344    27344           
==============================================
  Hits               20791    20791           
  Misses              6553     6553           
Flag Coverage Δ
NGOv2_project_testproject_ubuntu 75.07% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
com.unity.netcode.gameobjects 76.03% <ø> (ø)

ℹ️ Need help interpreting these results?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant