Skip to content

Add unit tests for protobuf encoder/decoder (oxide-sdk) #15

@niklabh

Description

@niklabh

Description

The oxide-sdk/src/proto.rs module implements a zero-dependency protobuf wire-format encoder (ProtoEncoder) and decoder (ProtoDecoder). Currently there are zero tests for this module.

Since the protobuf codec is the SDK's native serialisation format and is used by fetch_post_proto, it's important to have thorough test coverage.

Suggested test cases

  • Round-trip encoding/decoding for each wire type: uint32, uint64, int32, int64, sint32, sint64, bool, string, bytes, float, double, fixed32, fixed64, sfixed32, sfixed64
  • Nested messages — encode a message containing a sub-message, decode and verify
  • Empty message — encode with no fields, decode should yield no fields
  • Multiple fields — encode several fields, decode all of them in order
  • Edge cases — max/min values for integers, empty strings, empty byte arrays, very long strings
  • Unknown fields — decoder should gracefully skip unknown field numbers

Files involved

  • oxide-sdk/src/proto.rs — add a #[cfg(test)] mod tests { ... } block

Notes

  • The SDK compiles to wasm32-unknown-unknown in production, but tests run on the host target. Make sure tests are in a #[cfg(test)] module so they don't affect the WASM build.
  • Run tests with: cargo test -p oxide-sdk

Difficulty

Beginner to Intermediate — great way to learn Rust testing patterns and understand the protobuf wire format.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions