fixtures

package
v1.0.0-beta.43 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PaymailDomain is the "our" paymail domain in the tests.
	PaymailDomain = "example.com"
	// PaymailDomainExternal is the "their"/external paymail domain in the tests.
	PaymailDomainExternal = "external.example.com"

	// SenderExternalPKI is the PKI of the external Sender used in fixtures
	SenderExternalPKI = "02ed100a85ac774757c967e2a7a8a1c7fdef901795805b494df69d7d02f663d259"
	// RecipientExternalPKI is the PKI of the RecipientExternal used in fixtures
	RecipientExternalPKI = "03bf409b6b2842150142c6b92cb11ba6a06310bdacd0ff2118a9b9da60ed994c2b"
)

Variables

View Source
var (
	// UserWithMorePaymails is a user with more than one paymail.
	UserWithMorePaymails = User{
		Paymails: []Paymail{
			"tester@" + PaymailDomain,
			"second_pm@" + PaymailDomain,
		},
		PrivKey: "xprv9s21ZrQH143K29ipDWk4vbx6cyyfpbBSj84GrmQPpaKu9Nct6KBhxmSPaGHxoAPisgd3sXKdb2kqKpgLEeAoS54CQGZC8vjoQ6tmJceATxZ",
	}

	// UserWithoutPaymail is a user without any paymail.
	UserWithoutPaymail = User{
		PrivKey: "xprv9s21ZrQH143K4b2JYp37EzEcK55k5wQDnXaH3ooi8oq9yHEj8TCWGuVnJoQvQVyHx3eyF6DyLDiteD6G5CLdKvTcG8QwiEZPyqUcvgmj9aK",
	}

	// Sender is a user that is a sender in the tests.
	Sender = User{
		Paymails: []Paymail{
			"sender@" + PaymailDomain,
		},
		PrivKey: "xprv9s21ZrQH143K2stnKknNEck8NZ9buundyjYCGFGS31bwApaGp7oviHYVY9YAogmgvFC8EdsbsDReydnhDXrRrSXoNoMZczV9t4oPQREAmQ3",
	}

	// RecipientInternal is a user that is a recipient from "our" server in the tests.
	RecipientInternal = User{
		Paymails: []Paymail{
			"recipient@" + PaymailDomain,
		},
		PrivKey: "xprv9s21ZrQH143K3c3jkTBGijY5UsiHUdd3fSzRFD21c7cFduWX4m9nPrcuVrjQ76K234TFWgKF3f97HXggriPipBdhuof6bSvLGE74zCCgJds",
	}

	// RecipientExternal is a user that is a recipient from external server in the tests.
	RecipientExternal = User{
		Paymails: []Paymail{
			"recipient@" + PaymailDomainExternal,
		},
		PrivKey: "xprvA8mj2ZL1w6Nqpi6D2amJLo4Gxy24tW9uv82nQKmamT2rkg5DgjzJZRFnW33e7QJwn65uUWSuN6YQyWrujNjZdVShPRnpNUSRVTru4cxaqfd",
	}

	// SenderExternal is a user that is a sender from external server in the tests.
	SenderExternal = User{
		Paymails: []Paymail{
			"sender@" + PaymailDomainExternal,
		},
		PrivKey: "",
	}

	// ExternalFaucet is a user that is a faucet from external server in the tests.
	ExternalFaucet = User{
		Paymails: []Paymail{
			"faucet@" + PaymailDomainExternal,
		},
		PrivKey: "xprv9s21ZrQH143K3N6qVJQAu4EP51qMcyrKYJLkLgmYXgz58xmVxVLSsbx2DfJUtjcnXK8NdvkHMKfmmg5AJT2nqqRWUrjSHX29qEJwBgBPkJQ",
	}
)
View Source
var DefaultFeeUnit = bsv.FeeUnit{
	Satoshis: 1,
	Bytes:    1000,
}

DefaultFeeUnit is the default fee unit used in the tests.

View Source
var MockedBHSMerkleRootsData = []models.MerkleRoot{
	{
		BlockHeight: 0,
		MerkleRoot:  "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
	},
	{
		BlockHeight: 1,
		MerkleRoot:  "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098",
	},
	{
		BlockHeight: 2,
		MerkleRoot:  "9b0fc92260312ce44e74ef369f5c66bbb85848f2eddd5a7a1cde251e54ccfdd5",
	},
	{
		BlockHeight: 3,
		MerkleRoot:  "999e1c837c76a1b7fbb7e57baf87b309960f5ffefbf2a9b95dd890602272f644",
	},
	{
		BlockHeight: 4,
		MerkleRoot:  "df2b060fa2e5e9c8ed5eaf6a45c13753ec8c63282b2688322eba40cd98ea067a",
	},
	{
		BlockHeight: 5,
		MerkleRoot:  "63522845d294ee9b0188ae5cac91bf389a0c3723f084ca1025e7d9cdfe481ce1",
	},
	{
		BlockHeight: 6,
		MerkleRoot:  "20251a76e64e920e58291a30d4b212939aae976baca40e70818ceaa596fb9d37",
	},
	{
		BlockHeight: 7,
		MerkleRoot:  "8aa673bc752f2851fd645d6a0a92917e967083007d9c1684f9423b100540673f",
	},
	{
		BlockHeight: 8,
		MerkleRoot:  "a6f7f1c0dad0f2eb6b13c4f33de664b1b0e9f22efad5994a6d5b6086d85e85e3",
	},
	{
		BlockHeight: 9,
		MerkleRoot:  "0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9",
	},
	{
		BlockHeight: 10,
		MerkleRoot:  "d3ad39fa52a89997ac7381c95eeffeaf40b66af7a57e9eba144be0a175a12b11",
	},
	{
		BlockHeight: 11,
		MerkleRoot:  "f8325d8f7fa5d658ea143629288d0530d2710dc9193ddc067439de803c37066e",
	},
	{
		BlockHeight: 12,
		MerkleRoot:  "3b96bb7e197ef276b85131afd4a09c059cc368133a26ca04ebffb0ab4f75c8b8",
	},
	{
		BlockHeight: 13,
		MerkleRoot:  "9962d5c704ec27243364cbe9d384808feeac1c15c35ac790dffd1e929829b271",
	},
	{
		BlockHeight: 14,
		MerkleRoot:  "e1afd89295b68bc5247fe0ca2885dd4b8818d7ce430faa615067d7bab8640156",
	},
}

MockedBHSMerkleRootsData is mocked merkle roots data on Block Header Service (BHS) side

Functions

This section is empty.

Types

type GivenTXSpec

type GivenTXSpec interface {
	WithSender(sender User) GivenTXSpec
	WithRecipient(recipient User) GivenTXSpec
	WithoutSigning() GivenTXSpec
	WithInput(satoshis uint64) GivenTXSpec
	WithInputFromUTXO(tx *trx.Transaction, vout uint32) GivenTXSpec
	WithSingleSourceInputs(satoshis ...uint64) GivenTXSpec
	WithOPReturn(dataStr string) GivenTXSpec
	WithOutputScriptParts(parts ...ScriptPart) GivenTXSpec
	WithOutputScript(satoshis uint64, script *script.Script) GivenTXSpec
	WithP2PKHOutput(satoshis uint64) GivenTXSpec

	TX() *trx.Transaction
	InputUTXO(inputID int) bsv.Outpoint
	InputSourceTX(inputID int) *trx.Transaction
	ID() string
	BEEF() string
	RawTX() string
	EF() string
}

GivenTXSpec is a builder for creating MOCK! transactions

NOTE: Using several inputs in a single transaction is not recommended RIGHT NOW because: in that case the resulting BEEF hex will be varying because of the order of inputs TODO: Remove this comment after the go-sdk algorithm is fixed

func GivenTX

func GivenTX(t testing.TB) GivenTXSpec

GivenTX creates a new GivenTXSpec for building a MOCK! transaction

type OpCode

type OpCode byte

OpCode is an alias for byte to represent an opcode and implements ScriptPart for script building

func (OpCode) Append

func (op OpCode) Append(s *script.Script) error

Append appends the opcode to the script

type Paymail

type Paymail string

Paymail wraps a string paymail address to provide additional common methods.

func (Paymail) Address

func (p Paymail) Address() string

Address returns the address of this paymail.

func (Paymail) Alias

func (p Paymail) Alias() string

Alias returns the alias of this paymail.

func (Paymail) Domain

func (p Paymail) Domain() string

Domain returns the domain of this paymail.

func (Paymail) PublicName

func (p Paymail) PublicName() string

PublicName returns the public name of this paymail (for testing purposes, it's just the alias in uppercase).

func (Paymail) String

func (p Paymail) String() string

String is necessary to fulfill the fmt.Stringer interface.

type PushData

type PushData []byte

PushData is an alias for []byte to represent push data and implements ScriptPart for script building

func (PushData) Append

func (data PushData) Append(s *script.Script) error

Append appends the push data to the script

type ScriptPart

type ScriptPart interface {
	Append(s *script.Script) error
}

ScriptPart is an interface for building script parts

type User

type User struct {
	Paymails []Paymail
	PrivKey  string
}

User is a fixture that is representing a user of the system.

func AllUsers

func AllUsers() []User

AllUsers returns all users fixtures despite it's internal or external user.

func InternalUsers

func InternalUsers() []User

InternalUsers returns all users fixtures representing spv-wallet users.

func (*User) Address

func (f *User) Address() *script.Address

Address returns the address of this user.

func (*User) DefaultPaymail

func (f *User) DefaultPaymail() Paymail

DefaultPaymail returns the default paymail of this user.

func (*User) ID

func (f *User) ID() string

ID returns the id of the user. Warning: this refers to the new-tx-flow approach where v2 user's id is effectively P2PKH address from the public key.

func (*User) P2PKHLockingScript

func (f *User) P2PKHLockingScript() *script.Script

P2PKHLockingScript returns the locking script of this user.

func (*User) P2PKHUnlockingScriptTemplate

func (f *User) P2PKHUnlockingScriptTemplate(instructions ...bsv.CustomInstruction) *p2pkh.P2PKH

P2PKHUnlockingScriptTemplate returns the unlocking script template of this user.

func (*User) PrivateKey

func (f *User) PrivateKey() *ec.PrivateKey

PrivateKey returns the private key of this user.

func (*User) PublicKey

func (f *User) PublicKey() *ec.PublicKey

PublicKey returns the public key of this user.

func (*User) XPriv

func (f *User) XPriv() string

XPriv returns the xpriv of this user.

func (*User) XPrivHD

func (f *User) XPrivHD() *bip32.ExtendedKey

XPrivHD returns the xpriv of this user as a HD key.

func (*User) XPub

func (f *User) XPub() string

XPub returns the xpub of this user. We're calculating it to avoid mistakes in setting up the fixtures.

func (*User) XPubID

func (f *User) XPubID() string

XPubID returns the xpub id of this user. We're calculating it to avoid mistakes in setting up the fixtures.

Jump to

Keyboard shortcuts

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