aminotest

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2026 License: Apache-2.0, UNKNOWN, UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Overview

Package aminotest provides test helpers for verifying amino codec correctness across both the reflect-based codec and the genproto2 generated codec. Import from _test.go files in any package whose types are registered with amino.RegisterGenproto2Type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertCodecParity

func AssertCodecParity(t *testing.T, cdc *amino.Codec, v any)

AssertCodecParity verifies that v round-trips identically through both the reflect codec (MarshalReflect / UnmarshalReflect) and the genproto2 fast path (MarshalBinary2 / UnmarshalBinary2), with the two codecs agreeing on every wire byte and every decoded value.

Asserted invariants:

  1. Encoder parity: MarshalReflect(v) == MarshalBinary2(v).
  2. Size invariant: SizeBinary2(v) == len(MarshalBinary2(v)).
  3. Cross-decoder parity: UnmarshalReflect(bz) and UnmarshalBinary2(bz) produce deeply-equal values.
  4. Roundtrip fidelity: both decoded values reflect.DeepEqual to v. This is strict — test inputs must avoid touching memoized caches (e.g., don't call Commit.Hash() or MakeBlock() on the input, since those populate unexported fields that won't be set on a freshly decoded value and would spuriously fail DeepEqual).

v must be a non-nil pointer to a value whose type implements amino.PBMessager2 (i.e., a type registered with genproto2).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL