testutil

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testutil builds BEEF objects and a stand-in for overlay-bridge's header read API, for the host's tests.

The header API stand-in serves the bridge's NATIVE shape exactly (GET /v1/tip -> {hash,height,known}, GET /v1/root/{h} -> {height,merkleRoot,known}, 404 for a height it does not hold), so the host's real tracker client (overlay-bridge headers/chainclient) is what the tests exercise.

Index

Constants

View Source
const CarrierLockTime = 4102444800

CarrierLockTime is the committed-record carrier's nLockTime (2100-01-01): non-final by design.

View Source
const SourceHeight = 100

SourceHeight is the block the fixture's mined source sits in, alone, so its txid is the block's merkle root.

Variables

This section is empty.

Functions

func BEEF

func BEEF(t testing.TB, tx *transaction.Transaction) []byte

BEEF serializes tx with its ancestry (BRC-62 V1).

Types

type Fixture

type Fixture struct {
	Src *transaction.Transaction
	// contains filtered or unexported fields
}

Fixture is a mined source paying P2PKH outputs and spends of it.

func NewFixture

func NewFixture(t testing.TB, seed byte) *Fixture

NewFixture builds a source whose outputs are distinct per seed, so two fixtures never share a txid.

func (*Fixture) Carrier

func (f *Fixture) Carrier(t testing.TB, vout uint32) *transaction.Transaction

Carrier is a spend made non-final the way committed-record carriers are.

func (*Fixture) Chain

func (f *Fixture) Chain(t testing.TB, vout uint32, depth int) *transaction.Transaction

Chain spends the previous transaction's output 0, depth times, from output vout of the source.

func (*Fixture) Root

func (f *Fixture) Root() chainhash.Hash

Root is the merkle root of SourceHeight.

func (*Fixture) Spend

func (f *Fixture) Spend(t testing.TB, vout uint32) *transaction.Transaction

Spend returns a signed child spending the source's output vout, with two outputs.

func (*Fixture) Unlocker

func (f *Fixture) Unlocker() *p2pkh.P2PKH

Unlocker signs a spend of any output the fixture's key locks.

type Headers

type Headers struct {
	*httptest.Server
	// contains filtered or unexported fields
}

Headers is a stand-in header API.

func NewHeaders

func NewHeaders(tip uint32, roots map[uint32]chainhash.Hash) *Headers

NewHeaders serves roots up to tip.

func (*Headers) Set

func (h *Headers) Set(height uint32, root chainhash.Hash, tip uint32)

Set replaces the root at height (a reorg) and moves the tip.

Jump to

Keyboard shortcuts

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