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.
Description
The
oxide-sdk/src/proto.rsmodule 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
uint32,uint64,int32,int64,sint32,sint64,bool,string,bytes,float,double,fixed32,fixed64,sfixed32,sfixed64Files involved
oxide-sdk/src/proto.rs— add a#[cfg(test)] mod tests { ... }blockNotes
wasm32-unknown-unknownin 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.cargo test -p oxide-sdkDifficulty
Beginner to Intermediate — great way to learn Rust testing patterns and understand the protobuf wire format.