pcodectest

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package pcodectest is the canonical test wiring for the proto/p PVM codec set. proto/p carries no github.com/luxfi/codec import after the Wave 2A rip (#101); this helper package is the bridge that lets test suites under proto/p construct linearcodec-backed codecs without duplicating wire-registration logic across every test file.

Production callers (luxfi/node/vms/platformvm/...) construct their codecs inline. This helper exists strictly so the in-tree test files don't need to duplicate the wiring.

This file holds the codec-agnostic helpers — generic linearcodec / codec.Manager construction, sentinel error re-exports, and shared type aliases. PVM-specific helpers (NewPVMCodecs, NewPVMRuntimeCodec, NewMetadataCodec, NewWarpCodec, NewMessageCodec, NewPayloadCodec) live in pvm.go and import proto/p/{block,txs,warp,...}. The split keeps this file importable from tests in those same proto/p packages without closing a test-time import cycle.

Index

Constants

View Source
const VersionSize = codec.VersionSize

VersionSize re-exports codec.VersionSize — the on-wire length of the codec-version prefix (2 bytes). Tests that compute expected Marshal-output sizes subtract this constant to isolate the payload component; they reach for the re-export here to avoid importing luxfi/codec directly.

Variables

View Source
var ErrCantUnpackVersion = codec.ErrCantUnpackVersion

ErrCantUnpackVersion is re-exported from luxfi/codec so test files under proto/p can assert on the codec's "missing version byte" sentinel without importing luxfi/codec themselves.

View Source
var ErrInsufficientLength = wrappers.ErrInsufficientLength

ErrInsufficientLength is re-exported from luxfi/codec/wrappers for the same reason — proto/p test files can `require.ErrorIs(err, pcodectest.ErrInsufficientLength)` without picking up the wrappers import directly.

Functions

This section is empty.

Types

type CodecManager

type CodecManager = codec.Manager

CodecManager re-exports codec.Manager so test files can hold a concrete codec.Manager without importing luxfi/codec directly. Used in test files that need to register a custom codec versions table.

func MaxInt32Manager

func MaxInt32Manager() CodecManager

MaxInt32Manager returns a fresh codec.Manager sized for genesis-style blobs (math.MaxInt32 budget). Tests building genesis codecs reach for this rather than re-deriving the budget at every call site.

func MaxIntManager

func MaxIntManager() CodecManager

MaxIntManager returns a fresh codec.Manager sized for warp-style payloads (math.MaxInt budget — effectively unbounded).

func NewCodecManager

func NewCodecManager(maxSize uint64) CodecManager

NewCodecManager returns a fresh codec.Manager with the supplied max wire-payload size. Mirrors codec.NewManager(maxSize). Tests use this to register their own codec versions against a Manager.

func NewDefaultCodecManager

func NewDefaultCodecManager() CodecManager

NewDefaultCodecManager returns a fresh codec.Manager with the default max wire-payload size. Mirrors codec.NewDefaultManager().

type Errs

type Errs = wrappers.Errs

Errs re-exports wrappers.Errs (a multi-error accumulator the legacy platformvm tests use to fold multiple ErrorIs targets into a single require.NoError chain). proto/p test files use the type alias to keep the codec/wrappers import out of their import block.

type LinearCodec

type LinearCodec = linearcodec.Codec

LinearCodec re-exports linearcodec.Codec (the union of codec.Registry + codec.Codec) so test files can hold a concrete linear codec without importing luxfi/codec/linearcodec directly. Each call to NewLinearCodec returns its own fresh codec — no global state.

func NewLinearCodec

func NewLinearCodec() LinearCodec

NewLinearCodec returns a fresh linearcodec-backed Codec instance. Used by:

  • fx-style tests that need a `codec.Registry` parameter for `fx.Initialize(...)` but never exercise the wire codec.
  • fuzz tests that exercise MarshalInto / UnmarshalFrom directly against a Packer.
  • in-package _test.go files that need to build their own codec against package-internal RegisterTypes (the helper here can't import the package because that would close a test-time import cycle through proto/p/block / proto/p/txs).

func NewLinearCodecWithTags

func NewLinearCodecWithTags(tags ...string) LinearCodec

NewLinearCodecWithTags returns a fresh linearcodec.Codec with the supplied struct-tag names. Mirrors linearcodec.New([]string{tag...}). Used by the metadata codec wiring where v0:"true" / v1:"true" tags select per-version field sets.

type Packer

type Packer = wrappers.Packer

Packer re-exports wrappers.Packer so fuzz tests can build/read MarshalInto / UnmarshalFrom byte streams without importing the codec/wrappers subpackage directly. The fuzz tests need the raw Packer because they're exercising codec.MarshalInto codepaths that don't go through Manager.Marshal — pcodectest is the bridge.

Jump to

Keyboard shortcuts

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