Skip to content

test(go): add TransportEndpoints serialization tests - #5066

Open
SouthwestAsiaFloat wants to merge 2 commits into
apache:masterfrom
SouthwestAsiaFloat:tests-for-transportsendpoints
Open

SouthwestAsiaFloat wants to merge 2 commits into
apache:masterfrom
SouthwestAsiaFloat:tests-for-transportsendpoints

Conversation

@SouthwestAsiaFloat

@SouthwestAsiaFloat SouthwestAsiaFloat commented Nov 24, 2026 •

Copy link
Copy Markdown

Which issue does this PR address?

Closes #5037

Rationale

The Go SDK's TransportEndpoints previously lacked dedicated unit tests for binary serialization and deserialization. Existing indirect coverage did not verify port ordering, little-endian byte encoding, or handling of invalid input lengths.

What changed?

The existing tests did not explicitly cover the binary layout and edge cases of TransportEndpoints.

Added unit tests to verify little-endian encoding for all four ports (TCP, QUIC, HTTP, and WebSocket), rejection of inputs shorter than 8 bytes, and correct decoding when trailing bytes are present.

Also added a round-trip test to verify serialization and deserialization consistency, along with a check that GetBufferSize() returns 8.

Local Execution

Reran the Go checks from foreign/go at f252ab24 with Go 1.25.0 on macOS (arm64).

  • go test -count=1 -v ./... passed, including all four TestTransportEndpoints tests. The suite skipped 29 opt-in end-to-end tests because their server fixtures were not configured.
  • go vet ./... passed with no diagnostics.

Docs

  • No user-facing change.

AI Usage

  1. Tools: ChatGPT and Codex.
  2. Scope: ChatGPT helped explain Go serialization and review the test design. Codex added the Apache license header, updated the two short-input assertions to check ierror.ErrInvalidCommand, ran the local Go checks, and ran the four-role team review.
  3. Verification: Reviewed the test assertions against the expected binary layout and edge cases. The local Go test and vet results are recorded above.
  4. Code understanding: I understand the test logic and assertions and can explain every line of the submitted code if asked.

@github-actions

Copy link
Copy Markdown

Thanks for the PR. It is labeled S-waiting-on-review and queued for review.

If AI assistance was used to create this PR, you are required to run the team-review skill before opening it.

Slash commands (own line, regular comment) move it around the queue:

  • /ready - back to S-waiting-on-review after addressing feedback
  • /author - flip to S-waiting-on-author while you finish changes
  • /request-review @user-or-team - request a reviewer
  • /pin - exempt the PR from the stale bot, /unpin to undo

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Nov 24, 2026
@justinmclean

Copy link
Copy Markdown
Member

Thanks @SouthwestAsiaFloat, and welcome. As the description names ChatGPT, please run the team-review skill and post the result here. Please also confirm whether the tests pass locally, as the description says both pending and passing.

@SouthwestAsiaFloat

Copy link
Copy Markdown
Author

All four new TransportEndpoints tests passed locally at ccd1a1dd. I reran go test -count=1 -v ./contracts/... and go vet ./... from foreign/go with Go 1.25.0 on macOS arm64. Both commands exited with status 0. I corrected the conflicting test status in the PR description.

Codex ran the repository’s four-role team-review skill on that commit. Its verdict was REQUEST CHANGES. It reported two warnings:

The review also noted that the failure message names MatchLittleEndian when the method under test is MarshalBinary. Line 17

Three optional simplifications
  • Share the assertion for the two short input lengths. Line 23
  • Use direct struct comparison in the decode tests. Line 49
  • Drop the duplicate encoded-length check and keep the separate GetBufferSize() assertion. Line 65

Issue apache#5037 specifies ErrInvalidCommand for input shorter than eight bytes. Assert that error for empty and seven-byte inputs and add the required Apache license header to the test file.

Co-authored-by: Codex <noreply@openai.com>
@SouthwestAsiaFloat

Copy link
Copy Markdown
Author

The four-role team-review rerun on f252ab24 returned APPROVE from all four roles, with no critical findings or warnings. The test file now has the Apache license header. Both the empty and seven-byte inputs check errors.Is(err, ierror.ErrInvalidCommand).

I reran both Go checks from foreign/go with Go 1.25.0 on macOS arm64:

  • go test -count=1 -v ./... passed, including all four TestTransportEndpoints tests. The suite skipped 29 opt-in end-to-end tests because their server fixtures were not configured.
  • go vet ./... passed with no diagnostics.

One non-blocking nit remains. The byte comparison’s failure message names MatchLittleEndian instead of MarshalBinary. Line 37

The review also suggested two optional simplifications: compare the structs directly and drop the duplicate encoded-length assertion. Struct comparison · Length assertion

@SouthwestAsiaFloat

Copy link
Copy Markdown
Author

Thanks @SouthwestAsiaFloat, and welcome. As the description names ChatGPT, please run the team-review skill and post the result here. Please also confirm whether the tests pass locally, as the description says both pending and passing.

Have run the team-review skill and implement modifications accordingly, please review it when you are available. Merci beaucoup

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

S-waiting-on-review PR is waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Go SDK: add unit tests for TransportEndpoints

2 participants