itest

package
v0.8.0-rc2 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 97 Imported by: 0

Documentation

Index

Constants

View Source
const Subsystem = "ITST"

Variables

This section is empty.

Functions

func AssertAddr added in v0.3.0

func AssertAddr(t *testing.T, expected *taprpc.Asset, actual *taprpc.Addr)

AssertAddr asserts that an address contains the correct information of an asset.

func AssertAddrCreated added in v0.3.0

func AssertAddrCreated(t *testing.T, client tapClient,
	expected *taprpc.Asset, actual *taprpc.Addr)

AssertAddrCreated makes sure an address was created correctly for the given asset.

func AssertAddrEvent added in v0.3.0

func AssertAddrEvent(t *testing.T, client taprpc.TaprootAssetsClient,
	addr *taprpc.Addr, numEvents int,
	expectedStatus taprpc.AddrEventStatus)

AssertAddrEvent makes sure the given address was detected by the given daemon.

func AssertAddrEventByStatus added in v0.3.0

func AssertAddrEventByStatus(t *testing.T, client taprpc.TaprootAssetsClient,
	filterStatus taprpc.AddrEventStatus, numEvents int)

AssertAddrEventByStatus makes sure the given number of events exist with the given status.

func AssertAddrEventCustomTimeout added in v0.4.0

func AssertAddrEventCustomTimeout(t *testing.T,
	client taprpc.TaprootAssetsClient, addr *taprpc.Addr, numEvents int,
	expectedStatus taprpc.AddrEventStatus, timeout time.Duration)

AssertAddrEventCustomTimeout makes sure the given address was detected by the given daemon within the given timeout.

func AssertAsset added in v0.3.0

func AssertAsset(t *testing.T, expected, actual *taprpc.Asset)

AssertAsset asserts that two taprpc.Asset objects are equal, ignoring node-specific fields like if script keys are local, if the asset is spent, or if the anchor information is populated.

func AssertAssetGenesis added in v0.3.0

func AssertAssetGenesis(t *testing.T, expected, actual *taprpc.GenesisInfo)

AssertAssetGenesis asserts that two taprpc.GenesisInfo objects are equal.

func AssertAssetOutboundTransferWithOutputs added in v0.3.0

func AssertAssetOutboundTransferWithOutputs(t *testing.T,
	minerClient *miner.HarnessMiner, sender commands.RpcClientsBundle,
	transfer *taprpc.AssetTransfer, inputAssetIDs [][]byte,
	expectedAmounts []uint64, currentTransferIdx,
	numTransfers, numOutputs int, confirm bool) *wire.MsgBlock

AssertAssetOutboundTransferWithOutputs makes sure the given outbound transfer has the correct state and number of outputs.

func AssertAssetProofs added in v0.3.0

func AssertAssetProofs(t *testing.T, tapClient taprpc.TaprootAssetsClient,
	chainClient chainrpc.ChainKitClient, a *taprpc.Asset) []byte

AssertAssetProofs makes sure the proofs for the given asset can be retrieved from the given daemon and can be fully validated.

func AssertAssetProofsInvalid added in v0.3.0

func AssertAssetProofsInvalid(t *testing.T, tapd *tapdHarness,
	a *taprpc.Asset)

AssertAssetProofsInvalid makes sure the proofs for the given asset can be retrieved from the given daemon but fail to validate.

func AssertAssetState added in v0.3.0

func AssertAssetState(t *testing.T, assets map[string][]*taprpc.Asset,
	name string, metaHash []byte, assetChecks ...AssetCheck) *taprpc.Asset

AssertAssetState makes sure that an asset with the given (possibly non-unique!) name exists in the list of assets and then performs the given additional checks on that asset.

func AssertAssetStateByScriptKey added in v0.3.0

func AssertAssetStateByScriptKey(t *testing.T, assets []*taprpc.Asset,
	scriptKey []byte, assetChecks ...AssetCheck) *taprpc.Asset

AssertAssetStateByScriptKey makes sure that an asset with the given (possibly non-unique!) name exists in the list of assets and then performs the given additional checks on that asset.

func AssertAssetsMinted added in v0.3.0

func AssertAssetsMinted(t *testing.T, tapClient commands.RpcClientsBundle,
	assetRequests []*mintrpc.MintAssetRequest, mintTXID,
	blockHash chainhash.Hash) []*taprpc.Asset

AssertAssetsMinted makes sure all assets in the minting request were in fact minted in the given anchor TX and block. The function returns the list of minted assets.

func AssertBalanceByGroup added in v0.3.0

func AssertBalanceByGroup(t *testing.T, client taprpc.TaprootAssetsClient,
	hexGroupKey string, amt uint64, opts ...BalanceOption)

AssertBalanceByGroup asserts that the balance of a single asset group on the given daemon is correct.

func AssertBalanceByID added in v0.3.0

func AssertBalanceByID(t *testing.T, client taprpc.TaprootAssetsClient,
	id []byte, amt uint64)

AssertBalanceByID asserts that the balance of a single asset, specified by ID, on the given daemon is correct.

func AssertBalances added in v0.6.0

func AssertBalances(t *testing.T, client taprpc.TaprootAssetsClient,
	balance uint64, opts ...BalanceOption)

func AssertFeeRate added in v0.4.0

func AssertFeeRate(t *testing.T, minerClient *miner.HarnessMiner,
	inputAmt int64, txid *chainhash.Hash,
	feeRate chainfee.SatPerKWeight)

AssertFeeRate checks that the fee paid for a given TX is close to the expected fee for the same TX, at a given fee rate.

func AssertGenesisOutput added in v0.4.0

func AssertGenesisOutput(t *testing.T, output *taprpc.ManagedUtxo,
	sibling commitment.TapscriptPreimage)

func AssertGroup added in v0.3.0

func AssertGroup(t *testing.T, a *taprpc.Asset, b *taprpc.AssetHumanReadable,
	groupKey []byte)

AssertGroup asserts that an asset returned from the ListGroups call matches a specific asset and has the same group key.

func AssertGroupAnchor added in v0.3.0

func AssertGroupAnchor(t *testing.T, anchorGen *asset.Genesis,
	anchorGroup *taprpc.AssetGroup)

AssertGroupAnchor asserts that a specific asset genesis was used to create a tweaked group key.

func AssertGroupSizes added in v0.3.0

func AssertGroupSizes(t *testing.T, client taprpc.TaprootAssetsClient,
	hexGroupKeys []string, sizes []int)

AssertGroupSizes asserts that a set of groups the daemon is aware of contain the expected number of assets.

func AssertListAssets added in v0.3.0

func AssertListAssets(t *testing.T, ctx context.Context,
	client taprpc.TaprootAssetsClient, matchAssets []MatchRpcAsset)

AssertListAssets checks that the assets returned by ListAssets match the expected assets.

func AssertMintEvents added in v0.4.0

func AssertMintEvents(t *testing.T, batchKey []byte,
	stream *EventSubscription[*mintrpc.MintEvent])

AssertMintEvents makes sure all events with incremental status are sent on the stream for the given minting batch.

func AssertMintedAssetBalances added in v0.6.0

func AssertMintedAssetBalances(t *testing.T, client taprpc.TaprootAssetsClient,
	simpleAssets, issuableAssets []*taprpc.Asset, includeLeased bool)

func AssertMintingProofs added in v0.3.0

func AssertMintingProofs(t *testing.T, tapd *tapdHarness,
	requests []*mintrpc.MintAssetRequest, assets []*taprpc.Asset)

AssertMintingProofs make sure the asset minting proofs contain all the correct reveal information.

func AssertNonInteractiveRecvComplete added in v0.3.0

func AssertNonInteractiveRecvComplete(t *testing.T,
	receiver taprpc.TaprootAssetsClient, totalInboundTransfers int)

AssertNonInteractiveRecvComplete makes sure the given receiver has the correct number of completed non-interactive inbound asset transfers in their list of events.

func AssertNumAssets added in v0.4.0

func AssertNumAssets(t *testing.T, ctx context.Context,
	client taprpc.TaprootAssetsClient,
	numAssets int) *taprpc.ListAssetResponse

AssertNumAssets check the number of assets returned by ListAssets.

func AssertNumBurns added in v0.6.0

func AssertNumBurns(t *testing.T, client taprpc.TaprootAssetsClient,
	num int, req *taprpc.ListBurnsRequest) []*taprpc.AssetBurn

AssertNumBurns makes sure a given number of burns exists, then returns them.

func AssertNumGroups added in v0.3.0

func AssertNumGroups(t *testing.T, client taprpc.TaprootAssetsClient,
	num int)

AssertNumGroups asserts that the number of groups the daemon is aware of is correct.

func AssertProofAltLeaves added in v0.5.0

func AssertProofAltLeaves(t *testing.T, tapClient taprpc.TaprootAssetsClient,
	a *taprpc.Asset, leafMap map[string][]*asset.Asset)

AssertProofAltLeaves makes sure that, for a given asset, the latest proof commits to an expected set of altLeaves.

func AssertReceiveEvents added in v0.4.0

func AssertReceiveEvents(t *testing.T, addr *taprpc.Addr,
	stream *EventSubscription[*taprpc.ReceiveEvent])

AssertReceiveEvents makes sure all events with incremental status are sent on the stream for the given address.

func AssertReceiveEventsCustom added in v0.7.0

func AssertReceiveEventsCustom(t *testing.T,
	stream *EventSubscription[*taprpc.ReceiveEvent],
	status []taprpc.AddrEventStatus)

AssertReceiveEventsCustom makes sure we receive the expected events.

func AssertSendEventExecuteSendState added in v0.4.0

func AssertSendEventExecuteSendState(t *harnessTest,
	event *tapdevrpc.SendAssetEvent, broadcastState string) bool

AssertSendEventExecuteSendState asserts that the send asset event is an ExecuteSendState event, and logs the event timestamp if so.

func AssertSendEventProofTransferBackoffWaitTypeSend added in v0.4.0

func AssertSendEventProofTransferBackoffWaitTypeSend(t *harnessTest,
	event *tapdevrpc.SendAssetEvent) bool

AssertSendEventProofTransferBackoffWaitTypeSend asserts that the send asset event is a ProofTransferBackoffWait event, with the transfer type set as send.

func AssertSendEvents added in v0.4.0

func AssertSendEvents(t *testing.T, targetScriptKey []byte,
	stream *EventSubscription[*taprpc.SendEvent], from,
	to tapfreighter.SendState)

AssertSendEvents makes sure all events with incremental status are sent on the stream for the given script key.

func AssertSendEventsComplete added in v0.4.0

func AssertSendEventsComplete(t *testing.T, scriptKey []byte,
	stream *EventSubscription[*taprpc.SendEvent])

AssertSendEventsComplete makes sure the two remaining events for the given script key are sent on the stream.

func AssertSplitTombstoneTransfer added in v0.3.0

func AssertSplitTombstoneTransfer(t *testing.T,
	client taprpc.TaprootAssetsClient, id []byte)

AssertSplitTombstoneTransfer asserts that there is a transfer for the given asset ID that is a split that left over a tombstone output.

func AssertSupplyLeafBlockHeaders added in v0.7.0

func AssertSupplyLeafBlockHeaders(t *testing.T, expectedBlockHeight uint32,
	expectedTimestamp int64, expectedBlockHash chainhash.Hash,
	actualBlockHeaders map[uint32]*unirpc.SupplyLeafBlockHeader)

AssertSupplyLeafBlockHeaders makes sure that the given block header exists in the map of block headers and that its contents matches the expected values.

func AssertTransfer added in v0.3.0

func AssertTransfer(t *testing.T, client taprpc.TaprootAssetsClient,
	transferIdx, numTransfers int, outputAmounts []uint64)

AssertTransfer asserts that the value of each transfer initiated on the given daemon is correct.

func AssertTransferFeeRate added in v0.4.0

func AssertTransferFeeRate(t *testing.T, minerClient *miner.HarnessMiner,
	transferResp *taprpc.SendAssetResponse, inputAmt int64,
	feeRate chainfee.SatPerKWeight)

AssertTransferFeeRate checks that fee paid for the TX anchoring an asset transfer is close to the expected fee for that TX, at a given fee rate.

func AssertTxInBlock added in v0.3.0

func AssertTxInBlock(t *testing.T, block *wire.MsgBlock,
	txid *chainhash.Hash) *wire.MsgTx

AssertTxInBlock checks that a given transaction can be found in the block's transaction list.

func AssertUniverseAssetStats added in v0.3.0

func AssertUniverseAssetStats(t *testing.T, node *tapdHarness,
	assets []*taprpc.Asset)

func AssertUniverseKeysEqual added in v0.3.0

func AssertUniverseKeysEqual(t *testing.T, uniIDs []*unirpc.ID,
	a, b unirpc.UniverseClient)

func AssertUniverseLeavesEqual added in v0.3.0

func AssertUniverseLeavesEqual(t *testing.T, uniIDs []*unirpc.ID,
	a, b unirpc.UniverseClient)

func AssertUniverseRoot added in v0.3.0

func AssertUniverseRoot(t *testing.T, client unirpc.UniverseClient,
	sum int, assetID []byte, groupKey []byte)

AssertUniverseRoot makes sure the given universe root exists with the given sum, either identified by the asset ID or group key.

func AssertUniverseRootEqual added in v0.3.0

func AssertUniverseRootEqual(a, b *unirpc.UniverseRoot) bool

func AssertUniverseRootEquality added in v0.3.0

func AssertUniverseRootEquality(t *testing.T,
	clientA, clientB unirpc.UniverseClient, expectedEquality bool)

AssertUniverseRootEquality checks that the universe roots returned by two daemons are either equal or not, depending on the expectedEquality parameter.

func AssertUniverseRootEqualityEventually added in v0.4.0

func AssertUniverseRootEqualityEventually(t *testing.T,
	clientA, clientB unirpc.UniverseClient)

AssertUniverseRootEqualityEventually checks that the universe roots returned by two daemons are either equal eventually.

func AssertUniverseRootsEqual added in v0.3.0

func AssertUniverseRootsEqual(a, b *unirpc.AssetRootResponse) bool

func AssertUniverseStateEqual added in v0.3.0

func AssertUniverseStateEqual(t *testing.T, a, b unirpc.UniverseClient) bool

func AssertUniverseStats added in v0.3.0

func AssertUniverseStats(t *testing.T, client unirpc.UniverseClient,
	numProofs, numAssets, numGroups int)

func BuildMintingBatch added in v0.4.0

func BuildMintingBatch(t *testing.T, tapClient commands.RpcClientsBundle,
	assetRequests []*mintrpc.MintAssetRequest, opts ...MintOption)

func CommitVirtualPsbts added in v0.4.0

func CommitVirtualPsbts(t *testing.T, funder commands.RpcClientsBundle,
	packet *psbt.Packet, activePackets []*tappsbt.VPacket,
	passivePackets []*tappsbt.VPacket,
	changeOutputIndex int32) (*psbt.Packet, []*tappsbt.VPacket,
	[]*tappsbt.VPacket, *wrpc.CommitVirtualPsbtsResponse)

func CommitmentKey added in v0.3.0

func CommitmentKey(t *testing.T, rpcAsset *taprpc.Asset) [32]byte

CommitmentKey returns the asset's commitment key given an RPC asset representation.

func ConfirmAndAssertOutboundTransfer added in v0.3.0

func ConfirmAndAssertOutboundTransfer(t *testing.T,
	minerClient *miner.HarnessMiner, sender commands.RpcClientsBundle,
	sendResp *taprpc.SendAssetResponse, assetID []byte,
	expectedAmounts []uint64, currentTransferIdx,
	numTransfers int) *wire.MsgBlock

ConfirmAndAssertOutboundTransfer makes sure the given outbound transfer has the correct state before confirming it and then asserting the confirmed state with the node.

func ConfirmAndAssertOutboundTransferWithOutputs added in v0.4.0

func ConfirmAndAssertOutboundTransferWithOutputs(t *testing.T,
	minerClient *miner.HarnessMiner, sender commands.RpcClientsBundle,
	sendResp *taprpc.SendAssetResponse, assetID []byte,
	expectedAmounts []uint64, currentTransferIdx,
	numTransfers, numOutputs int) *wire.MsgBlock

ConfirmAndAssertOutboundTransferWithOutputs makes sure the given outbound transfer has the correct state and number of outputs before confirming it and then asserting the confirmed state with the node.

func ConfirmBatch added in v0.4.0

func ConfirmBatch(t *testing.T, minerClient *miner.HarnessMiner,
	tapClient commands.RpcClientsBundle,
	assetRequests []*mintrpc.MintAssetRequest,
	sub *EventSubscription[*mintrpc.MintEvent], mintTXID chainhash.Hash,
	batchKey []byte, opts ...MintOption) []*taprpc.Asset

func CopyRequest added in v0.3.0

CopyRequest is a helper function to copy a request so that we can modify it.

func CopyRequests added in v0.3.0

func CopyRequests(
	reqs []*mintrpc.MintAssetRequest) []*mintrpc.MintAssetRequest

CopyRequests is a helper function to copy a slice of requests so that we can modify them.

func DeriveKeys added in v0.4.0

func ExecTapCLI added in v0.5.1

func ExecTapCLI(ctx context.Context, tapClient *tapdHarness,
	args ...string) (interface{}, error)

ExecTapCLI uses the CLI parser to invoke the specified tapd harness via RPC, passing the provided arguments. It returns the response or an error.

func ExportProofFile added in v0.5.1

func ExportProofFile(t *testing.T, src *tapdHarness, assetID, scriptKey []byte,
	outpoint *taprpc.OutPoint) *taprpc.ProofFile

ExportProofFile waits until a proof file is available for the given asset, then returns the full provenance chain as a proof file.

func ExportProofFileFromUniverse added in v0.5.1

func ExportProofFileFromUniverse(t *testing.T, src commands.RpcClientsBundle,
	assetIDBytes, scriptKey []byte, outpoint string,
	group *taprpc.AssetGroup) *proof.File

ExportProofFileFromUniverse iteratively downloads the whole provenance proof chain from the given source universe and returns it as a proof file.

func FinalizeBatchUnconfirmed added in v0.4.0

func FinalizeBatchUnconfirmed(t *testing.T, minerClient *miner.HarnessMiner,
	tapClient commands.RpcClientsBundle,
	assetRequests []*mintrpc.MintAssetRequest,
	opts ...MintOption) (chainhash.Hash, []byte)

func FinalizePacket added in v0.4.0

func FinalizePacket(t *testing.T, lnd *rpc.HarnessRPC,
	pkt *psbt.Packet) *psbt.Packet

func GroupAssetsByName added in v0.3.0

func GroupAssetsByName(assets []*taprpc.Asset) map[string][]*taprpc.Asset

GroupAssetsByName converts an unordered list of assets to a map of lists of assets, where all assets in a list have the same name.

func ImportProofFile added in v0.5.1

func ImportProofFile(t *harnessTest, dst commands.RpcClientsBundle,
	rawFile proof.Blob)

ImportProofFile manually imports a proof file into the given node's universe, then registers the inbound transfer to make the wallet aware of the new asset it received.

func ImportProofFileDeprecated added in v0.5.1

func ImportProofFileDeprecated(t *harnessTest, dst commands.RpcClientsBundle,
	rawFile proof.Blob,
	genesisPoint string) *tapdevrpc.ImportProofResponse

ImportProofFileDeprecated manually imports a proof file using the development only ImportProof RPC.

func InsertProofIntoUniverse added in v0.5.1

func InsertProofIntoUniverse(t *testing.T, dst commands.RpcClientsBundle,
	proofBytes proof.Blob) *unirpc.AssetProofResponse

InsertProofIntoUniverse manually inserts a proof into the given node using the universe related InsertProof RPC.

func LargestUtxo added in v0.7.0

func LargestUtxo(t *testing.T, client taprpc.TaprootAssetsClient,
	assetID, groupKey []byte) *taprpc.Asset

LargestUtxo returns the largest asset UTXO for the given asset ID or group key. Fails if no assets are found.

func LogfTimestamped added in v0.3.0

func LogfTimestamped(t *testing.T, format string, args ...interface{})

LogfTimestamped logs the given message with the current timestamp.

func MakeOutput added in v0.4.0

func MakeOutput(t *harnessTest, wallet *node.HarnessNode,
	addrType lnrpc.AddressType, amount int64) *wire.TxOut

MakeOutput creates a new TXO from a given output type and amount.

func ManualMintSimpleAsset added in v0.4.0

func ManualMintSimpleAsset(t *harnessTest, lndNode *node.HarnessNode,
	tapClient *tapdHarness, commitVersion commitment.TapCommitmentVersion,
	req *mintrpc.MintAsset) (*taprpc.Asset, proof.Blob, string)

func MineBlocks added in v0.3.0

func MineBlocks(t *testing.T, minerClient *miner.HarnessMiner,
	num uint32, numTxs int) []*wire.MsgBlock

MineBlocks mine 'num' of blocks and check that blocks are present in node blockchain. numTxs should be set to the number of transactions (excluding the coinbase) we expect to be included in the first mined block.

func MintAssetExternalSigner added in v0.5.1

func MintAssetExternalSigner(t *harnessTest, tapNode *tapdHarness,
	assetReqs []*mintrpc.MintAssetRequest,
	externalSignerCallback ExternalSigCallback) []*taprpc.Asset

MintAssetExternalSigner is a helper function that mints a batch of assets and calls the external signer callback to sign the group virtual PSBT.

func MintAssetUnconfirmed added in v0.3.0

func MintAssetUnconfirmed(t *testing.T, minerClient *miner.HarnessMiner,
	tapClient commands.RpcClientsBundle,
	assetRequests []*mintrpc.MintAssetRequest,
	opts ...MintOption) (chainhash.Hash, []byte)

MintAssetUnconfirmed is a helper function that mints a batch of assets and waits until the minting transaction is in the mempool but does not mine a block.

func MintAssetsConfirmBatch added in v0.3.0

func MintAssetsConfirmBatch(t *testing.T, minerClient *miner.HarnessMiner,
	tapClient commands.RpcClientsBundle,
	assetRequests []*mintrpc.MintAssetRequest,
	opts ...MintOption) []*taprpc.Asset

MintAssetsConfirmBatch mints all given assets in the same batch, confirms the batch and verifies all asset proofs of the minted assets.

func MultiSigTest added in v0.4.0

func MultiSigTest(t *testing.T, ctx context.Context, aliceTapd,
	bobTapd commands.RpcClientsBundle, universeHostPort string,
	bitcoinClient *miner.HarnessMiner, aliceLnd, bobLnd *rpc.HarnessRPC,
	params *chaincfg.Params, testTimeout time.Duration)

MultiSigTest tests that we can use multi signature on all levels of the Taproot Assets Protocol. This includes the BTC level, the asset level and the group key level.

func NumGroups added in v0.3.0

func NumGroups(t *testing.T, client taprpc.TaprootAssetsClient) int

NumGroups returns the current number of asset groups present.

func ParseGenInfo added in v0.3.0

func ParseGenInfo(t *testing.T, genInfo *taprpc.GenesisInfo) *asset.Genesis

ParseGenInfo converts a taprpc.GenesisInfo into its asset.Genesis counterpart.

func PublishAndLogTransfer added in v0.6.0

func PublishAndLogTransfer(t *testing.T, tapd commands.RpcClientsBundle,
	btcPkt *psbt.Packet, activeAssets []*tappsbt.VPacket,
	passiveAssets []*tappsbt.VPacket,
	commitResp *wrpc.CommitVirtualPsbtsResponse,
	opts ...PublishAndLogTransferOption) *taprpc.SendAssetResponse

PublishAndLogTransfer is a helper function that invokes the PublishAndLogTransfer RPC endpoint on the specified tapd node. This endpoint performs a pre-anchored transfer.

func ResetNodeWallet added in v0.4.0

func ResetNodeWallet(t *harnessTest, wallet *node.HarnessNode)

ResetNodeWallet sets the wallet state of the given node to own 100 P2TR UTXOs of BTC, which matches the wallet state when initializing the itest harness.

func SetNodeUTXOs added in v0.4.0

func SetNodeUTXOs(t *harnessTest, wallet *node.HarnessNode,
	feeRate btcutil.Amount, reqs []*UTXORequest)

SetNodeUTXOs sets the wallet state for the given node wallet to a set of UTXOs of a specific type and value.

func SyncUniverses added in v0.4.0

func SyncUniverses(ctx context.Context, t *testing.T, clientTapd,
	universeTapd commands.RpcClientsBundle, universeHost string,
	timeout time.Duration, opts ...SyncUniverseOpt)

SyncUniverses syncs the universes of two tapd instances and waits until they are in sync.

func UpdateAndMineSupplyCommit added in v0.7.0

func UpdateAndMineSupplyCommit(t *testing.T, ctx context.Context,
	tapd unirpc.UniverseClient, miner *miner.HarnessMiner,
	groupKeyBytes []byte, expectedTxsInBlock int) []*wire.MsgBlock

UpdateAndMineSupplyCommit updates the on-chain supply commitment for an asset group and mines the commitment transaction.

func UseLogger added in v0.6.0

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

func VerifyGroupAnchor added in v0.3.0

func VerifyGroupAnchor(t *testing.T, assets []*taprpc.Asset,
	anchorName string) *taprpc.Asset

VerifyGroupAnchor verifies that the correct asset was used as the group anchor by re-deriving the group key.

func VerifyProofBlob added in v0.3.0

func VerifyProofBlob(t *testing.T, tapClient taprpc.TaprootAssetsClient,
	chainClient chainrpc.ChainKitClient, a *taprpc.Asset,
	blob proof.Blob) (*proof.File, *proof.AssetSnapshot)

VerifyProofBlob parses the given proof blob into a file, verifies it and returns the resulting last asset snapshot together with the parsed file.

func WaitForBatchState added in v0.3.0

func WaitForBatchState(t *testing.T, ctx context.Context,
	client mintrpc.MintClient, timeout time.Duration, batchKey []byte,
	targetState mintrpc.BatchState)

WaitForBatchState polls until the planter has reached the desired state with the given batch.

func WaitForNTxsInMempool added in v0.5.1

func WaitForNTxsInMempool(minerClient *miner.HarnessMiner, n int,
	timeout time.Duration) ([]*chainhash.Hash, error)

WaitForNTxsInMempool polls until finding the desired number of transactions in the provided miner's mempool. An error is returned if this number is not met after the given timeout.

func WaitForProofUpdate added in v0.3.0

func WaitForProofUpdate(t *testing.T, client taprpc.TaprootAssetsClient,
	a *taprpc.Asset, blockHeight int32)

WaitForProofUpdate polls until the proof for the given asset has been updated, which is detected by checking the block height of the last proof.

func WaitForSupplyCommit added in v0.7.0

func WaitForSupplyCommit(t *testing.T, ctx context.Context,
	tapd unirpc.UniverseClient, groupKeyBytes []byte,
	spentCommitOutpoint fn.Option[wire.OutPoint],
	condition func(*unirpc.FetchSupplyCommitResponse) bool,
) (*unirpc.FetchSupplyCommitResponse, wire.OutPoint)

WaitForSupplyCommit waits for a supply commitment to be available and returns it when the specified condition is met.

Types

type ApertureHarness

type ApertureHarness struct {
	// ListenAddr is the address that the aperture service is listening on.
	ListenAddr string

	// service is the instance of the aperture service that is running.
	Service *aperture.Aperture
}

ApertureHarness is an integration testing harness for the aperture service.

func NewApertureHarness added in v0.2.2

func NewApertureHarness(t *testing.T, port int) *ApertureHarness

NewApertureHarness creates a new instance of the aperture service. It returns a harness which includes useful values for testing.

func (*ApertureHarness) Start added in v0.2.2

func (h *ApertureHarness) Start(errChan chan error) error

Start starts the aperture service.

func (*ApertureHarness) Stop added in v0.2.2

func (h *ApertureHarness) Stop() error

Stop stops the aperture service.

type AssetCheck added in v0.3.0

type AssetCheck func(a *taprpc.Asset) error

AssetCheck is a function type that checks an RPC asset's property.

func AssetAmountCheck added in v0.3.0

func AssetAmountCheck(amt uint64) AssetCheck

AssetAmountCheck returns a check function that tests an asset's amount.

func AssetAnchorCheck added in v0.3.0

func AssetAnchorCheck(txid, blockHash chainhash.Hash) AssetCheck

AssetAnchorCheck returns a check function that tests an asset's anchor.

func AssetDecimalDisplayCheck added in v0.4.0

func AssetDecimalDisplayCheck(decDisplay uint32) AssetCheck

AssetDecimalDisplayCheck returns a check function that tests an asset's decimal display value. The check function requires that the rpc Asset has a non-nil decimal display value.

func AssetGroupInternalKeyCheck added in v0.4.0

func AssetGroupInternalKeyCheck(key *taprpc.KeyDescriptor) AssetCheck

func AssetGroupTapscriptRootCheck added in v0.4.0

func AssetGroupTapscriptRootCheck(root []byte) AssetCheck

func AssetIsGroupedCheck added in v0.4.0

func AssetIsGroupedCheck(newGrouped, grouped bool) AssetCheck

func AssetScriptKeyCheck added in v0.4.0

func AssetScriptKeyCheck(scriptKey *taprpc.ScriptKey) AssetCheck

func AssetScriptKeyIsBurnCheck added in v0.3.0

func AssetScriptKeyIsBurnCheck(isBurn bool) AssetCheck

AssetScriptKeyIsBurnCheck returns a check function that tests an asset's script key for being a burn key.

func AssetScriptKeyIsLocalCheck added in v0.3.0

func AssetScriptKeyIsLocalCheck(isLocal bool) AssetCheck

AssetScriptKeyIsLocalCheck returns a check function that tests an asset's script key for being a local key.

func AssetTypeCheck added in v0.3.0

func AssetTypeCheck(assetType taprpc.AssetType) AssetCheck

AssetTypeCheck returns a check function that tests an asset's type.

func AssetVersionCheck added in v0.3.0

func AssetVersionCheck(version taprpc.AssetVersion) AssetCheck

AssetVersionCheck returns a check function that tests an asset's version.

type BalanceOption added in v0.6.0

type BalanceOption func(*balanceConfig)

func WithAllScriptKeyTypes added in v0.6.0

func WithAllScriptKeyTypes() BalanceOption

func WithAssetID added in v0.6.0

func WithAssetID(assetID []byte) BalanceOption

func WithGroupKey added in v0.6.0

func WithGroupKey(groupKey []byte) BalanceOption

func WithGroupedAssetBalance added in v0.6.0

func WithGroupedAssetBalance(groupedAssetBalance uint64) BalanceOption

func WithIncludeLeased added in v0.6.0

func WithIncludeLeased() BalanceOption

func WithNumAnchorUtxos added in v0.6.0

func WithNumAnchorUtxos(numAnchorUtxos uint32) BalanceOption

func WithNumUtxos added in v0.6.0

func WithNumUtxos(numAssetUtxos uint32) BalanceOption

func WithScriptKey added in v0.6.0

func WithScriptKey(scriptKey []byte) BalanceOption

func WithScriptKeyType added in v0.6.0

func WithScriptKeyType(scriptKeyType asset.ScriptKeyType) BalanceOption

type ChantoolsHarness added in v0.5.1

type ChantoolsHarness struct {
	// contains filtered or unexported fields
}

ChantoolsHarness is a helper struct that provides a way to interact with the chantools binary.

func NewChantoolsHarness added in v0.5.1

func NewChantoolsHarness(t *testing.T) ChantoolsHarness

NewChantoolsHarness creates a new instance of the ChantoolsHarness struct.

func (*ChantoolsHarness) CreateWallet added in v0.5.1

func (c *ChantoolsHarness) CreateWallet(t *testing.T)

CreateWallet creates a new wallet using the chantools binary.

func (*ChantoolsHarness) DeriveKey added in v0.5.1

func (c *ChantoolsHarness) DeriveKey(t *testing.T) (string, string)

DeriveKey derives a new key using the chantools binary.

func (*ChantoolsHarness) SignPsbt added in v0.5.1

func (c *ChantoolsHarness) SignPsbt(t *testing.T, psbtStr string) psbt.Packet

SignPsbt signs a PSBT using the chantools binary.

type ClientEventStream added in v0.4.0

type ClientEventStream[T any] interface {
	Recv() (T, error)
	grpc.ClientStream
}

ClientEventStream is a generic interface for a client stream that allows us to receive events from a server.

type EventSubscription added in v0.4.0

type EventSubscription[T any] struct {
	ClientEventStream[T]
	Cancel context.CancelFunc

	// ShouldNotify is an optional filter predicate function that can be
	// used to filter events received from the client stream.
	//
	// If set, it will be called for each event received from the stream. If
	// it returns true, the event is returned. If it returns false, the
	// event is ignored and the next event is received from the stream.
	ShouldNotify func(T) (bool, error)
}

EventSubscription holds a generic client stream and its context cancel function.

func NewAddrWithEventStream added in v0.4.0

NewAddrWithEventStream creates a new TAP address and also registers a new event stream for receive events for the address.

func SubscribeReceiveEvents added in v0.4.0

SubscribeReceiveEvents subscribes to receive events and returns the event stream.

nolint: lll

func SubscribeSendEvents added in v0.4.0

SubscribeSendEvents subscribes to send events and returns the event stream.

nolint: lll

func (*EventSubscription[T]) Recv added in v0.6.0

func (e *EventSubscription[T]) Recv() (T, error)

Recv receives an event from the client stream. If a filter is set, it will check if the event matches the filter. If it does, it returns the event. If not, it continues receiving events until it finds one that matches the filter.

type ExternalSigCallback added in v0.5.1

type ExternalSigCallback func([]*mintrpc.UnsealedAsset) []ExternalSigRes

ExternalSigCallback is a callback function that is called to sign the group virtual PSBT with external signers.

type ExternalSigRes added in v0.5.1

type ExternalSigRes struct {
	SignedPsbt psbt.Packet
	AssetID    asset.ID
}

ExternalSigRes is a helper struct that holds the signed PSBT and the corresponding asset ID.

type IntegratedNetworkHarness

type IntegratedNetworkHarness struct {

	// Miner is the btcd miner used for block generation and funding.
	Miner *miner.HarnessMiner

	// FeeServiceURL is the URL of an external fee estimation service.
	// When set, --fee.url=<url> is passed to each new node's lnd args so
	// the sweeper can obtain fee estimates for high conf targets that
	// btcd's built-in estimator cannot handle in regtest.
	FeeServiceURL string

	// FeeService is the fee service instance, exposed so tests can
	// dynamically adjust fee rates (e.g., SetMinRelayFeerate).
	FeeService *lntest.FeeService
	// contains filtered or unexported fields
}

IntegratedNetworkHarness manages a set of IntegratedNodes for integration testing. It coordinates shared infrastructure such as chain backend configuration and node lifecycle.

func NewIntegratedNetworkHarness

func NewIntegratedNetworkHarness(t *testing.T, binary string,
	chainBackend node.BackendConfig,
	netParams *chaincfg.Params) *IntegratedNetworkHarness

NewIntegratedNetworkHarness creates a new network harness for integrated lnd+tapd node testing. The binary path should point to a compiled tapd-integrated-itest binary, and chainBackend provides the btcd (or other) connection arguments.

func (*IntegratedNetworkHarness) AssertChannelExists

func (h *IntegratedNetworkHarness) AssertChannelExists(
	node *IntegratedNode, chanPoint *wire.OutPoint,
	checks ...func(*lnrpc.Channel)) error

AssertChannelExists asserts that an active channel identified by the specified channel point exists from the point-of-view of the node. It takes an optional set of check functions which can be used to make further assertions using the channel's values.

func (*IntegratedNetworkHarness) AssertNodeKnown

func (h *IntegratedNetworkHarness) AssertNodeKnown(node,
	target *IntegratedNode) error

AssertNodeKnown asserts that node knows about target in the network graph.

func (*IntegratedNetworkHarness) CloseChannel

CloseChannel attempts to close the channel indicated by the passed channel point, initiated by the passed node. It returns the close channel stream and the close transaction hash.

func (*IntegratedNetworkHarness) ConnectNodes

func (h *IntegratedNetworkHarness) ConnectNodes(t *testing.T,
	a, b *IntegratedNode)

ConnectNodes establishes a p2p connection from node a to node b. The function blocks until b appears in a's peer list or a timeout is reached.

func (*IntegratedNetworkHarness) EnsureConnected

func (h *IntegratedNetworkHarness) EnsureConnected(t *testing.T,
	a, b *IntegratedNode)

EnsureConnected ensures that nodes a and b are connected, tolerating the "already connected" error if they already have a connection and retrying if the server is still starting up.

func (*IntegratedNetworkHarness) LookUpNodeByPub

func (h *IntegratedNetworkHarness) LookUpNodeByPub(
	pub string) (*IntegratedNode, error)

LookUpNodeByPub finds an active node by its hex-encoded public key.

func (*IntegratedNetworkHarness) NewNode

func (h *IntegratedNetworkHarness) NewNode(name string,
	extraLndArgs, extraTapdArgs []string) *IntegratedNode

NewNode creates, starts, and returns a new IntegratedNode. Chain backend connection args from the harness are automatically prepended to the node's lnd args so the caller only needs to pass test-specific overrides.

func (*IntegratedNetworkHarness) OpenChannel

OpenChannel opens a channel between srcNode and destNode with the given parameters. It waits for the "channel pending" notification and returns the open channel stream.

func (*IntegratedNetworkHarness) SendCoins

func (h *IntegratedNetworkHarness) SendCoins(t *testing.T,
	amt btcutil.Amount, target *IntegratedNode)

SendCoins sends amt satoshis from the miner to the target node using a P2WKH address. 6 blocks are mined afterward for confirmation.

func (*IntegratedNetworkHarness) StopAndBackupDB

func (h *IntegratedNetworkHarness) StopAndBackupDB(
	node *IntegratedNode) error

StopAndBackupDB stops the given node, creates a backup of its lnd data directory, and restarts the node. The backup can be restored later with StopAndRestoreDB to simulate a breach scenario.

func (*IntegratedNetworkHarness) StopAndRestoreDB

func (h *IntegratedNetworkHarness) StopAndRestoreDB(
	node *IntegratedNode) error

StopAndRestoreDB stops the given node, restores the lnd data directory from a previous backup (created by StopAndBackupDB), and restarts the node. This puts the node back into a previous channel state, which can be used to simulate a channel breach.

func (*IntegratedNetworkHarness) TearDown

func (h *IntegratedNetworkHarness) TearDown()

TearDown stops all active nodes managed by this harness.

func (*IntegratedNetworkHarness) WaitForChannelClose

WaitForChannelClose waits for a "channel close" notification on the given stream and returns the close update.

func (*IntegratedNetworkHarness) WaitForChannelOpen

func (h *IntegratedNetworkHarness) WaitForChannelOpen(
	openChanStream lnrpc.Lightning_OpenChannelClient) (
	*lnrpc.ChannelPoint, error)

WaitForChannelOpen waits for a "channel open" notification on the given stream and returns the channel point.

type IntegratedNode

type IntegratedNode struct {
	Cfg *IntegratedNodeConfig

	// PubKey is the compressed public key of this node, populated after
	// Start().
	PubKey [33]byte

	// PubKeyStr is the hex-encoded public key string, populated after
	// Start().
	PubKeyStr string

	// LND RPC clients.
	lnrpc.LightningClient
	lnrpc.StateClient
	routerrpc.RouterClient
	invoicesrpc.InvoicesClient
	walletrpc.WalletKitClient

	// Tapd RPC clients.
	taprpc.TaprootAssetsClient
	wrpc.AssetWalletClient
	mintrpc.MintClient
	rfqrpc.RfqClient
	tchrpc.TaprootAssetChannelsClient
	unirpc.UniverseClient
	tapdevrpc.TapDevClient
	authmailboxrpc.MailboxClient
	// contains filtered or unexported fields
}

IntegratedNode manages a running integrated lnd+tapd binary process and provides gRPC clients for both lnd and tapd RPCs.

func NewIntegratedNode

func NewIntegratedNode(t *testing.T, name, binaryPath string,
	netParams *chaincfg.Params, extraLndArgs,
	extraTapdArgs []string) *IntegratedNode

NewIntegratedNode creates a new IntegratedNode with allocated ports and temp directories. The node is not started yet; call Start() to launch it.

func (*IntegratedNode) P2PAddr

func (n *IntegratedNode) P2PAddr() string

P2PAddr returns the host:port address of this node's P2P listener.

func (*IntegratedNode) RPCAddr

func (n *IntegratedNode) RPCAddr() string

RPCAddr returns the host:port address of this node's gRPC server.

func (*IntegratedNode) Restart

func (n *IntegratedNode) Restart()

Restart stops the node and starts it again, preserving data directories.

func (*IntegratedNode) Start

func (n *IntegratedNode) Start()

Start launches the integrated binary as an external process and waits for its gRPC server to become available.

func (*IntegratedNode) Stop

func (n *IntegratedNode) Stop()

Stop sends SIGINT to the integrated binary and waits for it to exit.

func (*IntegratedNode) WaitForReady

func (n *IntegratedNode) WaitForReady(ctx context.Context)

WaitForReady polls lnd's GetInfo until it reports the node is fully synced and ready to accept operations.

type IntegratedNodeConfig

type IntegratedNodeConfig struct {
	// Name is the human-readable name for this node (e.g. "Alice").
	Name string

	// BinaryPath is the path to the tapd-integrated binary.
	BinaryPath string

	// BaseDir is the temp directory for this node's data.
	BaseDir string

	// RPCPort is the lnd gRPC port (also serves tapd services).
	RPCPort int

	// P2PPort is the lnd peer-to-peer port.
	P2PPort int

	// NetParams is the chain parameters to use.
	NetParams *chaincfg.Params

	// ExtraLndArgs are additional args passed under the --lnd.* namespace.
	ExtraLndArgs []string

	// ExtraTapdArgs are additional args under --taproot-assets.*.
	ExtraTapdArgs []string
}

IntegratedNodeConfig holds the configuration for an integrated lnd+tapd node.

type MatchRpcAsset

type MatchRpcAsset func(asset *taprpc.Asset) bool

MatchRpcAsset is a function that returns true if the given RPC asset is a match.

type MintOption added in v0.3.0

type MintOption func(*MintOptions)

func WithError added in v0.5.0

func WithError(errorText string) MintOption

WithError is an option to specify the string that is expected in the error returned by the FinalizeBatch call.

func WithFeeRate added in v0.5.0

func WithFeeRate(feeRate uint32) MintOption

func WithMintingTimeout added in v0.3.0

func WithMintingTimeout(timeout time.Duration) MintOption

func WithSiblingBranch added in v0.4.0

func WithSiblingBranch(branch mintrpc.FinalizeBatchRequest_Branch) MintOption

func WithSiblingTree added in v0.4.0

func WithSiblingTree(tree mintrpc.FinalizeBatchRequest_FullTree) MintOption

type MintOptions added in v0.3.0

type MintOptions struct {
	// contains filtered or unexported fields
}

func DefaultMintOptions added in v0.3.0

func DefaultMintOptions() *MintOptions

type Option

type Option func(*tapdHarnessParams)

Option is a tapd harness option.

func WithOracleServer added in v0.6.0

func WithOracleServer(global, override string) Option

WithOracleServer is a functional option that sets the oracle server address option to the provided string.

func WithPortfolioPilotServer

func WithPortfolioPilotServer(global, override string) Option

WithPortfolioPilotServer is a functional option that sets the portfolio pilot server address option to the provided string.

func WithSendPriceHint added in v0.7.0

func WithSendPriceHint() Option

WithSendPriceHint is a functional option that indicates that the tapd node should send price hints from the local oracle to the counterparty when requesting a quote.

func WithSweepOrphanUtxos

func WithSweepOrphanUtxos() Option

WithSweepOrphanUtxos enables sweeping zero-value anchor UTXOs for the tapd harness created with this option. Tests disable sweeping by default; this option re-enables it.

type OracleHarness

type OracleHarness struct {
	oraclerpc.UnimplementedPriceOracleServer

	// Mock is a mock object that can optionally be used to track calls to
	// the oracle harness. If no call expectations are set, the prices from
	// the maps below will be used.
	// NOTE: When setting up the call expectations, we need to use the
	// actual fields of the `QueryAssetRatesRequest` message, since
	// otherwise it is much harder to match the calls nicely.
	mock.Mock
	// contains filtered or unexported fields
}

OracleHarness is a basic integration test RPC price oracle server harness.

func NewOracleHarness

func NewOracleHarness(listenAddr string) *OracleHarness

NewOracleHarness returns a new oracle harness instance that is set to listen on the provided address with a default 5-minute quote expiry.

func NewOracleHarnessWithExpiry

func NewOracleHarnessWithExpiry(listenAddr string,
	expiryDelay time.Duration) *OracleHarness

NewOracleHarnessWithExpiry returns a new oracle harness instance with the given quote expiry delay.

func (*OracleHarness) QueryAssetRates

QueryAssetRates queries the asset rates for a given transaction type, subject asset, and payment asset. An asset rate is the number of asset units per BTC.

Example use case:

Alice is trying to pay an invoice by spending an asset. Alice therefore requests that Bob (her asset channel counterparty) purchase the asset from her. Bob's payment, in BTC, will pay the invoice.

Alice requests a bid quote from Bob. Her request includes an asset rates hint (ask). Alice obtains the asset rates hint by calling this endpoint. She sets: - `SubjectAsset` to the asset she is trying to sell. - `SubjectAssetMaxAmount` to the max channel asset outbound. - `PaymentAsset` to BTC. - `TransactionType` to SALE. - `AssetRateHint` to nil.

Bob calls this endpoint to get the bid quote asset rates that he will send as a response to Alice's request. He sets: - `SubjectAsset` to the asset that Alice is trying to sell. - `SubjectAssetMaxAmount` to the value given in Alice's quote request. - `PaymentAsset` to BTC. - `TransactionType` to PURCHASE. - `AssetRateHint` to the value given in Alice's quote request.

func (*OracleHarness) SetPrice

func (o *OracleHarness) SetPrice(specifier asset.Specifier, buyPrice,
	sellPrice rfqmath.BigIntFixedPoint)

SetPrice sets the target buy and sell price for the provided specifier.

func (*OracleHarness) Start

func (o *OracleHarness) Start(t *testing.T)

Start runs the oracle harness.

func (*OracleHarness) Stop

func (o *OracleHarness) Stop()

Stop terminates the oracle harness.

type PublishAndLogTransferOption added in v0.6.0

type PublishAndLogTransferOption func(*publishAndLogTransferOptions)

PublishAndLogTransferOption defines a functional option for PublishAndLogTransfer.

type SyncUniverseOpt added in v0.5.1

type SyncUniverseOpt func(*syncOptions)

SyncUniverseOpt is used to modify the parameters of a universe sync.

func WithSyncMode added in v0.5.1

func WithSyncMode(mode universerpc.UniverseSyncMode) SyncUniverseOpt

WithSyncMode can be used to define which sync mode to be used when performing a universe sync.

type UTXORequest added in v0.4.0

type UTXORequest struct {
	Type   lnrpc.AddressType
	Amount int64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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