xcodectest

package
v1.2.0 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: 6 Imported by: 0

Documentation

Overview

Package xcodectest is the canonical test wiring for the proto/x XVM codec set. proto/x carries no github.com/luxfi/codec import after the Wave 1A rip (#101); this helper package is the bridge that lets test suites under proto/x construct linearcodec-backed ParserCodecs.

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() txs.ParserCodecs

New returns a ParserCodecs bundle backed by two fresh linearcodec registries and two codec.Manager instances, one for runtime txs and one for genesis txs (with the larger MaxInt32 size budget). Each call produces independent codecs — safe to use per-test.

Tx-level and fx-owned wire payload types are registered when this bundle is handed to txs.NewParser — see parser.go fxOwnedTypes for the canonical per-fx registration list.

func NewRuntimeCodec

func NewRuntimeCodec() (txs.Codec, txs.Registry)

NewRuntimeCodec returns a single linearcodec-backed codec.Manager for runtime tx wire bytes. Used by tests that need a Codec directly without going through a Parser. Fx types are NOT auto-registered here — callers that need fx payload roundtrip should use New().

Types

type CodecMock

type CodecMock struct {
	// contains filtered or unexported fields
}

CodecMock is a gomock-driven mock of the txs.Codec interface.

It mirrors the legacy luxfi/codec/codecmock.Manager API surface so existing tests can be ported by swapping the import: codecmock.NewManager → xcodectest.NewCodecMock. The package deliberately does not depend on github.com/luxfi/codec — proto/x carries no such import after Wave 1A.

func NewCodecMock

func NewCodecMock(ctrl *gomock.Controller) *CodecMock

NewCodecMock creates a fresh CodecMock.

func (*CodecMock) EXPECT

func (m *CodecMock) EXPECT() *CodecMockRecorder

EXPECT returns the recorder so tests can program expectations.

func (*CodecMock) Marshal

func (m *CodecMock) Marshal(version uint16, source interface{}) ([]byte, error)

Marshal records the call and returns the configured result.

func (*CodecMock) Size

func (m *CodecMock) Size(version uint16, value interface{}) (int, error)

Size records the call and returns the configured result.

func (*CodecMock) Unmarshal

func (m *CodecMock) Unmarshal(source []byte, destination interface{}) (uint16, error)

Unmarshal records the call and returns the configured result.

type CodecMockRecorder

type CodecMockRecorder struct {
	// contains filtered or unexported fields
}

CodecMockRecorder is the mock recorder.

func (*CodecMockRecorder) Marshal

func (mr *CodecMockRecorder) Marshal(version, source any) *gomock.Call

Marshal expectation.

func (*CodecMockRecorder) Size

func (mr *CodecMockRecorder) Size(version, value any) *gomock.Call

Size expectation.

func (*CodecMockRecorder) Unmarshal

func (mr *CodecMockRecorder) Unmarshal(source, destination any) *gomock.Call

Unmarshal expectation.

Jump to

Keyboard shortcuts

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