goldentest

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package goldentest holds the helpers a package's tests share when they check themselves against a committed test vector: a fixed test key, hex and transaction parsing that fail the test rather than return an error, and a chain tracker that knows only the roots the test hands it.

It carries no vector of its own. Each application keeps its vector, and the code that finds and reads it, in its own tree: a path resolved from this package's source file would point into the module cache once the package is imported from there.

It is a test helper that happens to live outside a _test file so that several packages can share it; no binary should import it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fill

func Fill(b byte) [32]byte

Fill is a 32-byte array of one repeated byte.

func FixedKey

func FixedKey() *ec.PrivateKey

FixedKey is the TEST key vectors are generated from, fixed so that regenerating one reproduces it byte for byte. It must never be used for anything real: it is 32 bytes of 0x42.

func Hex

func Hex(t testing.TB, s string) []byte

Hex decodes or fails the test.

func Tx

Tx parses a transaction from hex or fails the test.

Types

type Tracker

type Tracker struct {
	Roots map[uint32]string
	Tip   uint32
}

Tracker is a chain tracker that knows exactly the roots it was given, so a test proves a BUMP against a root it chose rather than against anything live. Any other height, and a nil root, answers (false, nil), as a header client answers a height it holds no header for: a test of an unproven parent then meets "not proven", not an error that would take a different refusal path.

func (*Tracker) CurrentHeight

func (s *Tracker) CurrentHeight(context.Context) (uint32, error)

func (*Tracker) IsValidRootForHeight

func (s *Tracker) IsValidRootForHeight(_ context.Context, root *chainhash.Hash, height uint32) (bool, error)

Jump to

Keyboard shortcuts

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