Skip to content

Add proto serialization round-trip tests #10

@lanycrost

Description

@lanycrost

Problem statement

There are no tests that validate protobuf serialization/deserialization for the generated Go code. While the generated code is produced by well-tested protoc plugins, round-trip tests serve as regression guards for:

  • Oneof field behavior (frame with audio/video/binary)
  • Reserved field handling (fields 4, 5 in FlowControl)
  • google.protobuf.Struct serialization with complex JSON
  • Empty vs zero-value vs nil semantics
  • Large byte payload handling

Proposed change

Add a new test file gen/go/proto/transport/v1/proto_test.go (or proto_roundtrip_test.go):

func TestDataRequest_RoundTrip_AudioFrame(t *testing.T) {
    req := &transportv1.DataRequest{
        Frame: &transportv1.DataRequest_Audio{
            Audio: &transportv1.AudioFrame{
                Pcm:          []byte("audio-data"),
                SampleRateHz: 48000,
                Channels:     2,
                Codec:        "opus",
                TimestampMs:  1234567890,
            },
        },
    }
    data, err := proto.Marshal(req)
    // ... unmarshal and compare
}

func TestDataRequest_RoundTrip_AllFrameTypes(t *testing.T) { ... }
func TestControlRequest_AllActions(t *testing.T) { ... }
func TestFlowControl_ReservedFieldsNotGenerated(t *testing.T) { ... }
func TestStreamEnvelope_ChunkingFields(t *testing.T) { ... }
func TestDataPacket_StructPayload_ComplexJSON(t *testing.T) { ... }

Affected area

  • Proto definitions
  • Generated bindings

Compatibility / migration

Test-only. No behavior change.

Additional context

Identified during QA review. These tests are particularly valuable before proto schema changes — they serve as the safety net that buf-breaking checks complement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/protoProto definitions, message design, or wire compatibility work.good first issueSmall, well-scoped tasks for new contributors.help wantedLooking for community contributions.kind/testsTesting, CI, or verification-only changes.priority/lowNice-to-have or backlog item.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions