Skip to content

Commit 58c9cfd

Browse files
committed
Add code docs
1 parent a120878 commit 58c9cfd

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

com.unity.netcode.gameobjects/Tests/Runtime/DistributedAuthority/DistributedAuthorityCodecTests.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@
1616

1717
namespace Unity.Netcode.RuntimeTests
1818
{
19+
/// <summary>
20+
/// This class tests the NGO message codec between the C# SDK and the Rust runtime.
21+
/// </summary>
22+
/// <remarks>
23+
/// These tests are run against a rust echo-server.
24+
/// This server decodes incoming messages, and then re-encodes them before sending them back to the client.
25+
/// Any errors in decoding or encoding messages will not echo the messages back, causing the tests to fail
26+
/// No message handling logic is tested in these tests. They are only testing the codec.
27+
/// The tests check if they can bind to a rust echo-server at the given address and port, if all tests are ignored.
28+
/// The rust echo-server is run using `cargo run --example ngo_echo_server -- --port {port}`
29+
/// The C# port can be configured using the environment variable "ECHO_SERVER_PORT"
30+
/// </remarks>
1931
internal class DistributedAuthorityCodecTests : NetcodeIntegrationTest
2032
{
2133
protected override int NumberOfClients => 1;
@@ -30,13 +42,17 @@ internal class DistributedAuthorityCodecTests : NetcodeIntegrationTest
3042
private NetworkManager Client => m_ClientNetworkManagers[0];
3143

3244
private string m_TransportHost = Environment.GetEnvironmentVariable("NGO_HOST") ?? "127.0.0.1";
33-
private static readonly ushort k_TransportPort = GetPortToBind(7777);
45+
private static readonly ushort k_TransportPort = GetPortToBind();
3446
private const int k_ClientId = 0;
3547

36-
private static ushort GetPortToBind(ushort defaultPort)
48+
/// <summary>
49+
/// Configures the port to look for the rust echo-server.
50+
/// </summary>
51+
/// <returns>The port from the environment variable "ECHO_SERVER_PORT" if it is set and valid; otherwise uses port 7777</returns>
52+
private static ushort GetPortToBind()
3753
{
3854
var value = Environment.GetEnvironmentVariable("ECHO_SERVER_PORT");
39-
return ushort.TryParse(value, out var configuredPort) ? configuredPort : defaultPort;
55+
return ushort.TryParse(value, out var configuredPort) ? configuredPort : (ushort)7777;
4056
}
4157

4258
private GameObject m_SpawnObject;

0 commit comments

Comments
 (0)