Skip to content

Commit cde309a

Browse files
style
Verbosity and clarity pass for the tests added.
1 parent 6b8df1d commit cde309a

5 files changed

Lines changed: 59 additions & 121 deletions

File tree

com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/NativeInterpolatorTests.cs

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ namespace Unity.Netcode.RuntimeTests
1212
/// measurement sequences and compares them step for step.
1313
/// </summary>
1414
/// <remarks>
15-
/// The two exist in parallel: the managed one continues to serve
16-
/// <see cref="TransformSyncModes.PerInstance"/> and the native one serves
17-
/// <see cref="TransformSyncModes.Batched"/>, because the managed one cannot run inside a job. Unlike the
18-
/// delta check, which the two synchronization modes genuinely share, there is nothing structural stopping
19-
/// these two from drifting apart. This is what stops it.
15+
/// The two exist in parallel: the managed one serves <see cref="TransformSyncModes.PerInstance"/> and the
16+
/// native one serves <see cref="TransformSyncModes.Batched"/>, because the managed one cannot run inside a
17+
/// job. Nothing structural keeps them from drifting apart.
2018
/// </remarks>
2119
// These tests do not need to run against the Rust server.
2220
[IgnoreIfServiceEnvironmentVariableSet]
@@ -33,18 +31,14 @@ internal class NativeInterpolatorTests
3331
private const float k_Tolerance = 1E-4f;
3432

3533
/// <summary>
36-
/// Allowed while a value is still in motion, for the two paths that are known to be sensitive rather
37-
/// than exact.
34+
/// Allowed while a value is still in motion, for the two paths that are equivalent rather than exact.
3835
/// </summary>
3936
/// <remarks>
40-
/// Vector slerp is the one replacement in <see cref="NetworkTransformMath"/> that is equivalent rather
41-
/// than exact, so its small per step difference compounds through the interpolator's feedback.
37+
/// Vector slerp is the one <see cref="NetworkTransformMath"/> replacement that is equivalent rather
38+
/// than exact, so its small per step difference compounds through the interpolator's feedback.<br />
4239
/// Quaternion smooth dampening converts to euler angles, dampens each angle, and converts back every
43-
/// frame; near a gimbal transition a sub thousandth of a degree difference in the conversion is enough
44-
/// to select a different (equally valid) euler representative, after which the two dampen toward
45-
/// different angles. The managed implementation is just as fragile there, so this is the two diverging
46-
/// under a shared weakness rather than one of them being wrong.<br /><br />
47-
/// What matters is that neither drifts permanently, which is what the settle phase asserts.
40+
/// frame. Near a gimbal transition a sub thousandth of a degree difference selects a different, equally
41+
/// valid, euler representative, and the two then dampen toward different angles.
4842
/// </remarks>
4943
private const float k_TransientTolerance = 5.0f;
5044

@@ -88,9 +82,6 @@ private NativeInterpolatorState CreateState(InterpolatorValueKind kind, bool isS
8882
};
8983
}
9084

91-
/// <summary>
92-
/// A deterministic motion path, so a failure is reproducible.
93-
/// </summary>
9485
private static Vector3 PositionAt(int tick)
9586
{
9687
return new Vector3(
@@ -334,19 +325,14 @@ public void BufferOverflowKeepsNewestMeasurement()
334325
}
335326

336327
/// <summary>
337-
/// An instance that stops being the authority part way through a session resets its interpolator, and
338-
/// the measurements that follow are stamped with the tick they were authored on.<br />
339-
/// Those stamps are older than the reset, so a seeded baseline would leave both ordering guards
340-
/// rejecting them. Neither implementation seeds one, and this holds them to that.
328+
/// An interpolator reset part way through a session still accepts the measurements that follow it.
341329
/// </summary>
342330
/// <remarks>
343-
/// This is the shape of an ownership transfer away from the local instance. It happens to the server
344-
/// under a server authoritative motion model and to the previous owner under an owner authoritative
345-
/// one.<br />
346-
/// It is reproduced here rather than only through
347-
/// <c>NetworkTransformSyncModeParityTests.OwnershipChangeKeepsReplicating</c> because the failure is
348-
/// entirely internal to the interpolator. Once the buffered measurements are all older than a seeded
349-
/// baseline, no amount of elapsed time recovers it.
331+
/// The reset stamps its baseline with the local time, while the measurements that follow carry the
332+
/// older tick they were authored on. See
333+
/// <see cref="BufferedLinearInterpolator{T}.ResetTo(T, double)"/>.<br />
334+
/// This is the shape of an ownership transfer away from the local instance: the server under server
335+
/// authority, the previous owner under owner authority.
350336
/// </remarks>
351337
[Test]
352338
public void ResetPartWayThroughSessionStillAcceptsOlderStampedMeasurements([Values] bool useManaged)

com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/NetworkTransformMathTests.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ namespace Unity.Netcode.RuntimeTests
1212
/// Measures how closely <see cref="NetworkTransformMath"/> agrees with the engine math it replaces.
1313
/// </summary>
1414
/// <remarks>
15-
/// The replacements exist because the engine equivalents are native bindings that Burst cannot compile.
16-
/// Some of them are ports of implementations that are managed C# in the engine and are expected to match
17-
/// exactly; the rest are mathematically equivalent but cannot be verified as bit identical because the
18-
/// engine's operation order is not observable.<br /><br />
19-
/// Each test reports the worst disagreement it found, so a failure states the actual measured error rather
20-
/// than just that a threshold was crossed.
15+
/// The replacements exist because the engine equivalents are native bindings Burst cannot compile.<br />
16+
/// Some are ports of engine code that is managed C#, and those are expected to match exactly.<br />
17+
/// The rest are mathematically equivalent, and cannot be verified as bit identical because the engine's
18+
/// operation order is not observable.
2119
/// </remarks>
2220
// These tests do not need to run against the Rust server.
2321
[IgnoreIfServiceEnvironmentVariableSet]
@@ -41,10 +39,8 @@ internal class NetworkTransformMathTests
4139
/// over the value ranges used here, but not bit for bit.
4240
/// </summary>
4341
/// <remarks>
44-
/// The remaining difference is one rounding step, not an algorithmic one: every other ported function
45-
/// (including the scalar <see cref="NetworkTransformMath.SmoothDampAngle"/>, which shares this
46-
/// arithmetic) matches exactly. Chasing it would mean guessing at how the engine's build contracts
47-
/// multiply and add, and a difference this size is far below anything interpolation can express.
42+
/// Not worth closing: it would mean guessing at how the engine's build contracts multiply and add, and
43+
/// a difference this size is far below anything interpolation can express.
4844
/// </remarks>
4945
private const float k_SingleUlpTolerance = 1E-5f;
5046

com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/NetworkTransformStateBaselineTests.cs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ namespace Unity.Netcode.RuntimeTests
1515
/// configurations that drive its serialization branches.
1616
/// </summary>
1717
/// <remarks>
18-
/// This exists as the wire format baseline. Any change to how a state is written (whether intentional or
19-
/// not) will fail <see cref="NetworkTransformStateSerializationBaseline"/> with the new signatures, which
20-
/// makes an unintended wire change impossible to land silently.<br /><br />
21-
/// To (re)generate the baseline: run this test, copy the C# array literal it prints on failure into
22-
/// <see cref="k_ExpectedSignatures"/>, and verify every changed entry is an intended wire format change.
18+
/// To regenerate: run this test, copy the array literal it prints on failure into
19+
/// <see cref="k_ExpectedSignatures"/>, and confirm every changed entry is an intended wire format change.
2320
/// </remarks>
2421
// These tests do not need to run against the Rust server.
2522
[IgnoreIfServiceEnvironmentVariableSet]
@@ -28,9 +25,6 @@ internal class NetworkTransformStateBaselineTests
2825
/// <summary>
2926
/// One entry per case in <see cref="BuildStateMatrix"/>, formatted as "name|byteLength|fnv1aHash".
3027
/// </summary>
31-
/// <remarks>
32-
/// Empty until generated. See the remarks on the class for how to populate it.
33-
/// </remarks>
3428
private static readonly string[] k_ExpectedSignatures =
3529
{
3630
"FullPrecision.AllAxes|42|B454AEF3",
@@ -406,8 +400,8 @@ public void NetworkTransformStateSerializationBaseline()
406400
/// Verifies every configuration in the matrix survives a write and read back.
407401
/// </summary>
408402
/// <remarks>
409-
/// The baseline above proves the bytes did not change. This proves those bytes still round trip, which
410-
/// keeps a baseline that was regenerated against a broken serializer from being accepted.
403+
/// The baseline proves the bytes did not change. This proves they still round trip, so a baseline
404+
/// regenerated against a broken serializer is not silently accepted.
411405
/// </remarks>
412406
[Test]
413407
public void NetworkTransformStateSerializationRoundTrip()
@@ -460,10 +454,9 @@ public void NetworkTransformStateSerializationRoundTrip()
460454
/// <see cref="FlagStates.ReliableSequenced"/>.
461455
/// </summary>
462456
/// <remarks>
463-
/// <see cref="NetworkTransformState.UpdateReliability"/> is what derives ReliableSequenced, and
464-
/// <see cref="Serialize"/> takes the state by value and calls it on that copy.<br />
465-
/// The flag therefore reaches the bytes and the state read back from them, but never the source state
466-
/// the case holds. Comparing it against the source would always fail.
457+
/// <see cref="NetworkTransformState.UpdateReliability"/> derives ReliableSequenced, and
458+
/// <see cref="Serialize"/> takes the state by value and calls it on that copy. The flag reaches the
459+
/// bytes and the state read back from them, but never the source state the case holds.
467460
/// </remarks>
468461
private static void AssertFlagsSurvived(StateCase stateCase, NetworkTransformState deserialized)
469462
{

com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/NetworkTransformSyncModeConfigurationTests.cs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ namespace Unity.Netcode.RuntimeTests
1212
/// fixed for the duration of a session.
1313
/// </summary>
1414
/// <remarks>
15-
/// Nothing covered this before: every other fixture reaches the mode through the same assignment the
16-
/// harness makes, so a delivery path that never ran would still leave them all green. The two assertions
17-
/// here are the ones that fail if it stops arriving, or if it starts arriving in the middle of a session.
15+
/// Every other fixture reaches the mode through the same assignment the harness makes, so none of them
16+
/// can see a delivery path that never ran.
1817
/// </remarks>
1918
// These tests do not need to run against the Rust server, and batching is client-server only.
2019
[IgnoreIfServiceEnvironmentVariableSet]
@@ -46,9 +45,6 @@ protected override void OnServerAndClientsCreated()
4645
base.OnServerAndClientsCreated();
4746
}
4847

49-
/// <summary>
50-
/// Spawns an instance and returns the authority side <see cref="NetworkTransform"/>.
51-
/// </summary>
5248
private NetworkTransform SpawnMover()
5349
{
5450
var instance = Object.Instantiate(m_MoverPrefab);
@@ -71,10 +67,6 @@ private bool IsRegisteredForBatching(NetworkTransform networkTransform)
7167
/// The authored mode has to reach every <see cref="NetworkManager"/> and route the instances that
7268
/// spawn under it.
7369
/// </summary>
74-
/// <remarks>
75-
/// This is the one that would have caught the mode being configured but never delivered: the traffic
76-
/// stayed per instance while everything reporting on the configuration said otherwise.
77-
/// </remarks>
7870
[UnityTest]
7971
public IEnumerator AuthoredModeReachesTheRuntime()
8072
{
@@ -92,12 +84,6 @@ public IEnumerator AuthoredModeReachesTheRuntime()
9284
/// <summary>
9385
/// Writing the mode while a session is running applies to the next session, not this one.
9486
/// </summary>
95-
/// <remarks>
96-
/// The field is public so a project can offer it in its own pre-session UI, which means a mid-session
97-
/// write has to be inert rather than trusted. Taking effect immediately would leave already spawned
98-
/// instances registered under one mode while new ones use the other, and would move the connection
99-
/// configuration hash out from under clients still joining.
100-
/// </remarks>
10187
[UnityTest]
10288
public IEnumerator ModeChangedDuringASessionDoesNotAffectIt()
10389
{

0 commit comments

Comments
 (0)