test

package
v0.4.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HexCompressedPubKeyLen = hex.EncodedLen(btcec.PubKeyBytesLenCompressed)
	HexTaprootPkScript     = hex.EncodedLen(input.P2TRSize)

	DefaultHashLockWitness = []byte("foobar")
)

Functions

func BuildTapscriptTree added in v0.4.0

func BuildTapscriptTree(t *testing.T, useHashLock, valid bool,
	internalKey *btcec.PublicKey) (*txscript.TapLeaf, *waddrmgr.Tapscript,
	*psbt.TaprootTapLeafScript, []byte, []byte)

BuildTapscriptTree builds a Tapscript tree with two leaves, a hash lock script and a signature verification script. It also returns the data needed to satisfy one of the two leaves.

func BuildTapscriptTreeNoReveal added in v0.4.0

func BuildTapscriptTreeNoReveal(t *testing.T,
	internalKey *btcec.PublicKey) txscript.TapBranch

BuildTapscriptTreeNoReveal builds a Tapscript tree with two leaves, a hash lock script and a signature verification script.

func ComputeTaprootScript

func ComputeTaprootScript(t testing.TB, taprootKey *btcec.PublicKey) []byte

func ComputeTaprootScriptErr added in v0.3.0

func ComputeTaprootScriptErr(witnessProgram []byte) ([]byte, error)

func HexPubKey added in v0.3.0

func HexPubKey(pk *btcec.PublicKey) string

func HexSchnorrPubKey added in v0.3.0

func HexSchnorrPubKey(pk *btcec.PublicKey) string

func HexSignature added in v0.3.0

func HexSignature(sig *schnorr.Signature) string

func HexTx added in v0.3.0

func HexTx(t testing.TB, tx *wire.MsgTx) string

func Parse32Byte added in v0.3.0

func Parse32Byte(t testing.TB, b string) [32]byte

func Parse33Byte added in v0.3.0

func Parse33Byte(t testing.TB, b string) [33]byte

func ParseChainHash added in v0.3.0

func ParseChainHash(t testing.TB, hash string) chainhash.Hash

func ParseHex added in v0.3.0

func ParseHex(t testing.TB, b string) []byte

func ParseOutPoint added in v0.3.0

func ParseOutPoint(t testing.TB, op string) wire.OutPoint

func ParsePubKey added in v0.3.0

func ParsePubKey(t testing.TB, key string) *btcec.PublicKey

func ParseRPCKeyDescriptor

func ParseRPCKeyDescriptor(t testing.TB,
	rpcDesc *signrpc.KeyDescriptor) keychain.KeyDescriptor

func ParseSchnorrPubKey added in v0.3.0

func ParseSchnorrPubKey(t testing.TB, key string) *btcec.PublicKey

func ParseSchnorrSig added in v0.3.0

func ParseSchnorrSig(t testing.TB, sigHex string) *schnorr.Signature

func ParseTestVectors added in v0.3.0

func ParseTestVectors(t testing.TB, fileName string, target any)

func ParseTx added in v0.3.0

func ParseTx(t testing.TB, tx string) *wire.MsgTx

func PubToKeyDesc

func PubToKeyDesc(p *btcec.PublicKey) keychain.KeyDescriptor

func RandBool

func RandBool() bool

RandBool rolls a random boolean.

func RandBytes

func RandBytes(num int) []byte

func RandFlip added in v0.4.0

func RandFlip[T any](t, f T) T

RandFlip picks one of two values randomly.

func RandHash

func RandHash() chainhash.Hash

func RandInt

func RandInt[T constraints.Integer]() T

RandInt makes a random integer of the specified type.

func RandInt31n added in v0.3.0

func RandInt31n(n int32) int32

RandInt31n returns a random 32-bit integer in the range [0, n).

func RandIntn added in v0.3.0

func RandIntn(n int) int

RandIntn returns a random integer in the range [0, n).

func RandKeyDesc added in v0.4.0

func RandKeyDesc(t testing.TB) (keychain.KeyDescriptor, *btcec.PrivateKey)

func RandOp

func RandOp(t testing.TB) wire.OutPoint

func RandPrivKey

func RandPrivKey(_ testing.TB) *btcec.PrivateKey

func RandPubKey

func RandPubKey(t testing.TB) *btcec.PublicKey

func RandRead added in v0.3.0

func RandRead(t testing.TB, b []byte)

RandRead fills the passed byte slice with random data.

func RandTapLeaf added in v0.4.0

func RandTapLeaf(customScriptLen *int) txscript.TapLeaf

func RandTxWitnesses

func RandTxWitnesses(t testing.TB) wire.TxWitness

func ReadTestDataFile added in v0.4.0

func ReadTestDataFile(t *testing.T, fileName string) string

ReadTestDataFile reads a file from the testdata directory and returns its content as a string.

func SchnorrKey

func SchnorrKey(t testing.TB, pubKey *btcec.PublicKey) *btcec.PublicKey

func SchnorrKeysEqual added in v0.4.0

func SchnorrKeysEqual(t testing.TB, a, b *btcec.PublicKey) bool

func SchnorrPubKey

func SchnorrPubKey(t testing.TB, privKey *btcec.PrivateKey) *btcec.PublicKey

func ScriptCltv added in v0.4.0

func ScriptCltv(t *testing.T, cltv int64) txscript.TapLeaf

ScriptCltv returns a simple bitcoin script that locks the funds with a CLTV lock until the given block height.

func ScriptCltv0 added in v0.4.0

func ScriptCltv0(t *testing.T) txscript.TapLeaf

ScriptCltv0 returns a simple bitcoin script that locks the funds with a CLTV lock until block height 0. The script is explicitly invalid as it should return a clean stack error on evaluation.

func ScriptCsv added in v0.4.0

func ScriptCsv(t *testing.T, csv int64) txscript.TapLeaf

ScriptCsv returns a simple bitcoin script that locks the funds with a CSV lock for the given number of blocks.

func ScriptCsv0 added in v0.4.0

func ScriptCsv0(t *testing.T) txscript.TapLeaf

ScriptCsv0 returns a simple bitcoin script that locks the funds with a CSV lock for the zero blocks. The script is explicitly invalid as it should return a clean stack error on evaluation.

func ScriptHashLock

func ScriptHashLock(t *testing.T, preimage []byte) txscript.TapLeaf

ScriptHashLock returns a simple bitcoin script that locks the funds to a hash lock of the given preimage.

func ScriptSchnorrSig

func ScriptSchnorrSig(t *testing.T, pubKey *btcec.PublicKey) txscript.TapLeaf

ScriptSchnorrSig returns a simple bitcoin script that locks the funds to a Schnorr signature of the given public key.

func WriteTestFileHex added in v0.3.0

func WriteTestFileHex(t testing.TB, fileName string, content []byte)

func WriteTestVectors added in v0.3.0

func WriteTestVectors(t testing.TB, fileName string, target any)

Types

This section is empty.

Jump to

Keyboard shortcuts

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