goldentest

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 8 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 goldentest reads the shared test vector, testdata/golden/finger-v1.json.

One vector, generated once from a fixed test key by carrier's golden test and checked by every package: token, carrier, mint, verify, and the TypeScript host modules. Each reader parses it with its own code, so a disagreement between two implementations fails a test instead of a lookup.

Beside it, testdata/golden/mint-v1.json pins the bytes of the mined transactions mint builds (a funding tree, a payment) over this vector's funding outputs. Only the Go mint package reads it; regenerate it with `go test ./internal/protocol/mint -update` whenever finger-v1.json changes.

The helpers that know nothing of this vector (Fill, FixedKey, Hex, Tx and Tracker) are the package of the same name in github.com/lightwebinc/bcommon, and the names here re-export them so finger's tests call them under this package's name; Tracker is an alias, so StubTracker's result is the library's type. Path and Load stay here: Path finds the vector from this file's own location, which in the library would be the module cache, and -update would write there.

It is a test helper that happens to live outside a _test file so that several packages can share it; nothing in the binary imports 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 the vector is generated from. It must never be used for anything real: it is 32 bytes of 0x42.

func Hex

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

Hex decodes or fails the test.

func Path

func Path() string

Path is the vector's location, resolved from this file so every package's test finds it whatever its own directory.

func Tx

Tx parses a transaction from hex or fails the test.

Types

type Golden

type Golden struct {
	PrivateKeyHex        string `json:"privateKeyHex"`
	IdentityKeyHex       string `json:"identityKeyHex"`
	ProfileLockingKeyHex string `json:"profileLockingKeyHex"`
	RecordLockingKeyHex  string `json:"recordLockingKeyHex"`

	FundingTxHex   string `json:"fundingTxHex"`
	FundingBumpHex string `json:"fundingBumpHex"`
	FundingRootHex string `json:"fundingRootHex"`
	FundingHeight  uint32 `json:"fundingHeight"`

	Carrier1TxHex     string `json:"carrier1TxHex"`
	Carrier1RecordHex string `json:"carrier1RecordHex"`
	Carrier1CHex      string `json:"carrier1CHex"`
	Witness1Hex       string `json:"witness1Hex"`
	Token1ScriptHex   string `json:"token1ScriptHex"`
	Token1TxHex       string `json:"token1TxHex"`

	Carrier2TxHex     string `json:"carrier2TxHex"`
	Carrier2RecordHex string `json:"carrier2RecordHex"`
	Carrier2CHex      string `json:"carrier2CHex"`
	Witness2Hex       string `json:"witness2Hex"`
	Token2ScriptHex   string `json:"token2ScriptHex"`
	Token2TxHex       string `json:"token2TxHex"`

	// SweepTxHex is the kill switch: a transaction spending funding outputs
	// 0, 1 and 3 of the tree (the two the carriers used and a spare).
	SweepTxHex string `json:"sweepTxHex"`

	Mutations struct {
		Carrier1MineableTxHex       string `json:"carrier1MineableTxHex"`
		Token1BadSigScriptHex       string `json:"token1BadSigScriptHex"`
		Carrier2BadWitnessTxHex     string `json:"carrier2BadWitnessTxHex"`
		Carrier2BadWitnessRecordHex string `json:"carrier2BadWitnessRecordHex"`
	} `json:"mutations"`
}

Golden is the vector's shape. Hex throughout; C values are the carrier txid in hash byte order, not display order.

func Load

func Load(t *testing.T) *Golden

Load reads the committed vector.

func (*Golden) Funding

func (g *Golden) Funding(t *testing.T) *transaction.Transaction

Funding returns the golden funding tree with its merkle path attached.

func (*Golden) StubTracker

func (g *Golden) StubTracker() *Tracker

StubTracker knows the golden funding root at the golden height.

type Tracker

type Tracker = bcgoldentest.Tracker

Tracker is a chain tracker that knows exactly the roots it was given. It is the Tracker of github.com/lightwebinc/bcommon/goldentest under this package's name.

Jump to

Keyboard shortcuts

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