itest

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 55 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 taprpc.TaprootAssetsClient,
	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 AssertAsset added in v0.3.0

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

assertEqualAsset 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 AssertAssetBalances added in v0.3.0

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

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 *rpcclient.Client, sender TapdClient,
	transfer *taprpc.AssetTransfer, assetID []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 TapdClient,
	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)

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 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 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 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 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 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 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 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 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 *rpcclient.Client, sender TapdClient,
	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 ConfirmAndAssetOutboundTransferWithOutputs added in v0.3.0

func ConfirmAndAssetOutboundTransferWithOutputs(t *testing.T,
	minerClient *rpcclient.Client, sender TapdClient,
	sendResp *taprpc.SendAssetResponse, assetID []byte,
	expectedAmounts []uint64, currentTransferIdx,
	numTransfers, numOutputs int) *wire.MsgBlock

ConfirmAndAssetOutboundTransferWithOutputs 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 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 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 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 MineBlocks added in v0.3.0

func MineBlocks(t *testing.T, client *rpcclient.Client,
	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 MintAssetUnconfirmed added in v0.3.0

func MintAssetUnconfirmed(t *testing.T, minerClient *rpcclient.Client,
	tapClient TapdClient, 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 *rpcclient.Client,
	tapClient TapdClient, 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 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 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 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.

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 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 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 WithMintingTimeout added in v0.3.0

func WithMintingTimeout(timeout time.Duration) 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)

type TapdClient added in v0.3.0

TapdClient is the interface that is used to interact with a tapd instance.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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