Skip to content

geolocation: add cross-language fixture tests for Borsh deserialization #3306

@ben-dz

Description

@ben-dz

Problem

The geolocation Go SDK tests only verify round-trip consistency within Go itself. They do not prove the Go Borsh deserialization matches the actual Rust Borsh output. If there's a subtle encoding difference (e.g., Ipv4Addr serialization, String length prefix handling, enum discriminant encoding), the Go tests would pass but deserialization of real onchain data would fail.

The serviceability and telemetry SDKs both have fixture-based cross-language tests that catch this class of bug. The geolocation SDK should follow the same pattern.

What to do

Add a Rust fixture generator and Go fixture tests following the established pattern:

  1. Rust generator (sdk/geolocation/testdata/fixtures/generate-fixtures/src/main.rs):

    • Serialize GeolocationProgramConfig, GeoProbe, and GeolocationUser (with targets) using Borsh
    • Write paired .bin + .json files (binary data + field metadata)
  2. Go fixture test (sdk/geolocation/go/fixture_test.go):

    • Load .bin/.json pairs
    • Deserialize binary using Go SDK
    • Validate each field against the JSON metadata
  3. Wire into make generate-fixtures and make sdk-test

Reference implementations

  • sdk/serviceability/testdata/fixtures/generate-fixtures/src/main.rs
  • sdk/serviceability/go/fixture_test.go

Context

Identified during architecture review of #3305. Tracked separately so the read SDK can merge without blocking on this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions