testsuite

package
v2.0.0-beta.6 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: Apache-2.0 Imports: 32 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestProfileCaches = &profile.Caches{
	Addresses: &profile.CacheOpts{
		CacheTime:                  "200ms",
		ReleaseExecutorWorkerCount: 10,
		LeakDetectionOptions: &profile.LeakDetectionOpts{
			Enabled:               false,
			MaxConsumersPerObject: 20,
			MaxConsumerHoldTime:   "100s",
		},
	},
	Children: &profile.CacheOpts{
		CacheTime:                  "5s",
		ReleaseExecutorWorkerCount: 10,
		LeakDetectionOptions: &profile.LeakDetectionOpts{
			Enabled:               false,
			MaxConsumersPerObject: 20,
			MaxConsumerHoldTime:   "100s",
		},
	},
	Milestones: &profile.CacheOpts{
		CacheTime:                  "2.5s",
		ReleaseExecutorWorkerCount: 10,
		LeakDetectionOptions: &profile.LeakDetectionOpts{
			Enabled:               false,
			MaxConsumersPerObject: 20,
			MaxConsumerHoldTime:   "100s",
		},
	},
	Blocks: &profile.CacheOpts{
		CacheTime:                  "5s",
		ReleaseExecutorWorkerCount: 10,
		LeakDetectionOptions: &profile.LeakDetectionOpts{
			Enabled:               false,
			MaxConsumersPerObject: 20,
			MaxConsumerHoldTime:   "100s",
		},
	},
	UnreferencedBlocks: &profile.CacheOpts{
		CacheTime:                  "100ms",
		ReleaseExecutorWorkerCount: 10,
		LeakDetectionOptions: &profile.LeakDetectionOpts{
			Enabled:               false,
			MaxConsumersPerObject: 20,
			MaxConsumerHoldTime:   "100s",
		},
	},
	IncomingBlocksFilter: &profile.CacheOpts{
		CacheTime:                  "2.5s",
		ReleaseExecutorWorkerCount: 10,
		LeakDetectionOptions: &profile.LeakDetectionOpts{
			Enabled:               false,
			MaxConsumersPerObject: 20,
			MaxConsumerHoldTime:   "100s",
		},
	},
}

Functions

This section is empty.

Types

type Block

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

func (*Block) BookOnWallets

func (m *Block) BookOnWallets() *Block

func (*Block) GeneratedUTXO

func (m *Block) GeneratedUTXO() *utxo.Output

func (*Block) IotaBlock

func (m *Block) IotaBlock() *iotago.Block

func (*Block) Store

func (m *Block) Store() *Block

func (*Block) StoredBlock

func (m *Block) StoredBlock() *storage.Block

func (*Block) StoredBlockID

func (m *Block) StoredBlockID() iotago.BlockID

type BlockBuilder

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

func (*BlockBuilder) Amount

func (b *BlockBuilder) Amount(amount uint64) *BlockBuilder

func (*BlockBuilder) BuildAlias

func (b *BlockBuilder) BuildAlias() *Block

func (*BlockBuilder) BuildFoundryOnAlias

func (b *BlockBuilder) BuildFoundryOnAlias(aliasOutput *utxo.Output) *Block

func (*BlockBuilder) BuildTaggedData

func (b *BlockBuilder) BuildTaggedData() *Block

func (*BlockBuilder) BuildTransactionSendingOutputsAndCalculateRemainder

func (b *BlockBuilder) BuildTransactionSendingOutputsAndCalculateRemainder(outputs ...iotago.Output) *Block

func (*BlockBuilder) BuildTransactionToWallet

func (b *BlockBuilder) BuildTransactionToWallet(wallet *utils.HDWallet) *Block

func (*BlockBuilder) BuildTransactionWithInputsAndOutputs

func (b *BlockBuilder) BuildTransactionWithInputsAndOutputs(consumedInputs utxo.Outputs, outputs iotago.Outputs, signingWallets []*utils.HDWallet) *Block

func (*BlockBuilder) FakeInputs

func (b *BlockBuilder) FakeInputs() *BlockBuilder

func (*BlockBuilder) FromWallet

func (b *BlockBuilder) FromWallet(wallet *utils.HDWallet) *BlockBuilder

func (*BlockBuilder) LatestMilestoneAsParents

func (b *BlockBuilder) LatestMilestoneAsParents() *BlockBuilder

func (*BlockBuilder) Parents

func (b *BlockBuilder) Parents(parents iotago.BlockIDs) *BlockBuilder

func (*BlockBuilder) TagData

func (b *BlockBuilder) TagData(data []byte) *BlockBuilder

func (*BlockBuilder) ToWallet

func (b *BlockBuilder) ToWallet(wallet *utils.HDWallet) *BlockBuilder

func (*BlockBuilder) UsingOutput

func (b *BlockBuilder) UsingOutput(output *utxo.Output) *BlockBuilder

type MockCoo

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

func (*MockCoo) LastMilestoneBlockID

func (coo *MockCoo) LastMilestoneBlockID() iotago.BlockID

func (*MockCoo) LastMilestoneID

func (coo *MockCoo) LastMilestoneID() iotago.MilestoneID

LastMilestoneID calculates the milestone ID of the last issued milestone.

func (*MockCoo) LastMilestoneIndex

func (coo *MockCoo) LastMilestoneIndex() iotago.MilestoneIndex

func (*MockCoo) LastMilestoneParents

func (coo *MockCoo) LastMilestoneParents() iotago.BlockIDs

func (*MockCoo) LastMilestonePayload

func (coo *MockCoo) LastMilestonePayload() *iotago.Milestone

func (*MockCoo) LastPreviousMilestoneID

func (coo *MockCoo) LastPreviousMilestoneID() iotago.MilestoneID

LastPreviousMilestoneID returns the PreviousMilestoneID of the last issued milestone.

type OnLedgerUpdatedFunc

type OnLedgerUpdatedFunc func(index iotago.MilestoneIndex, newOutputs utxo.Outputs, newSpents utxo.Spents)

type OnMilestoneConfirmedFunc

type OnMilestoneConfirmedFunc func(confirmation *whiteflag.Confirmation)

type TestEnvironment

type TestEnvironment struct {
	// TestInterface is the common interface for tests and benchmarks.
	TestInterface testing.TB

	// Milestones are the created milestones by the coordinator during the test.
	Milestones storage.CachedMilestones

	// PoWHandler holds the PoWHandler instance.
	PoWHandler *pow.Handler

	// TempDir is the directory that contains the temporary files for the test.
	TempDir string

	// GenesisOutput marks the initial output created when bootstrapping the tangle.
	GenesisOutput *utxo.Output

	// OnLedgerUpdatedFunc callback that will be called after the ledger gets updated during confirmation. This is equivalent to the tangle.LedgerUpdated event.
	OnLedgerUpdatedFunc OnLedgerUpdatedFunc
	// contains filtered or unexported fields
}

TestEnvironment holds the state of the test environment.

func SetupTestEnvironment

func SetupTestEnvironment(testInterface testing.TB, genesisAddress *iotago.Ed25519Address, numberOfMilestones int, protocolVersion byte, belowMaxDepth uint8, targetScore uint32, showConfirmationGraphs bool) *TestEnvironment

SetupTestEnvironment initializes a clean database with initial snapshot, configures a coordinator with a clean state, bootstraps the network and issues the first "numberOfMilestones" milestones.

func (*TestEnvironment) AssertBlockConflictReason

func (te *TestEnvironment) AssertBlockConflictReason(blockID iotago.BlockID, conflict storage.Conflict)

func (*TestEnvironment) AssertFoundryTokenScheme

func (te *TestEnvironment) AssertFoundryTokenScheme(foundryOutput *utxo.Output, minted uint64, melted uint64, maxSupply uint64)

func (*TestEnvironment) AssertLedgerBalance

func (te *TestEnvironment) AssertLedgerBalance(wallet *utils.HDWallet, expectedBalance uint64)

AssertLedgerBalance generates an address for the given seed and index and checks correct balance.

func (*TestEnvironment) AssertTotalSupplyStillValid

func (te *TestEnvironment) AssertTotalSupplyStillValid()

AssertTotalSupplyStillValid checks if the total supply in the database is still correct.

func (*TestEnvironment) AssertWalletBalance

func (te *TestEnvironment) AssertWalletBalance(wallet *utils.HDWallet, expectedBalance uint64)

AssertWalletBalance generates an address for the given seed and index and checks correct balance.

func (*TestEnvironment) BelowMaxDepth

func (te *TestEnvironment) BelowMaxDepth() iotago.MilestoneIndex

func (*TestEnvironment) BuildTangle

func (te *TestEnvironment) BuildTangle(initBlocksCount int,
	belowMaxDepth int,
	milestonesCount int,
	minBlocksPerMilestone int,
	maxBlocksPerMilestone int,
	onNewBlock func(cmi iotago.MilestoneIndex, blockMetadata *storage.BlockMetadata),
	milestoneTipSelectFunc func(blocksIDs iotago.BlockIDs, blockIDsPerMilestones []iotago.BlockIDs) iotago.BlockIDs,
	onNewMilestone func(msIndex iotago.MilestoneIndex, blockIDs iotago.BlockIDs, conf *whiteflag.Confirmation, confStats *whiteflag.ConfirmedMilestoneStats)) (blockIDs iotago.BlockIDs, blockIDsPerMilestones []iotago.BlockIDs)

BuildTangle builds a tangle structure without a tipselection algorithm, but random tips from the last blocks in the last belowMaxDepth milestones.

func (*TestEnvironment) CleanupTestEnvironment

func (te *TestEnvironment) CleanupTestEnvironment(removeTempDir bool)

CleanupTestEnvironment cleans up everything at the end of the test.

func (*TestEnvironment) ComputeAddressBalanceWithoutConstraints

func (te *TestEnvironment) ComputeAddressBalanceWithoutConstraints(address iotago.Address, options ...utxo.IterateOption) (balance uint64, count int, err error)

func (*TestEnvironment) ConfigureUTXOCallbacks

func (te *TestEnvironment) ConfigureUTXOCallbacks(onLedgerUpdatedFunc OnLedgerUpdatedFunc)

func (*TestEnvironment) ConfirmMilestone

func (te *TestEnvironment) ConfirmMilestone(ms *storage.Milestone, createConfirmationGraph bool) (*whiteflag.Confirmation, *whiteflag.ConfirmedMilestoneStats)

ConfirmMilestone confirms the milestone for the given index.

func (*TestEnvironment) IssueAndConfirmMilestoneOnTips

func (te *TestEnvironment) IssueAndConfirmMilestoneOnTips(tips iotago.BlockIDs, createConfirmationGraph bool) (*whiteflag.Confirmation, *whiteflag.ConfirmedMilestoneStats)

IssueAndConfirmMilestoneOnTips creates a milestone on top of the given tips and confirms it.

func (*TestEnvironment) IssueMilestoneOnTips

func (te *TestEnvironment) IssueMilestoneOnTips(tips iotago.BlockIDs, addLastMilestoneAsParent bool) (*storage.Milestone, iotago.BlockID, error)

IssueMilestoneOnTips creates a milestone on top of the given tips.

func (*TestEnvironment) LastMilestoneBlockID

func (te *TestEnvironment) LastMilestoneBlockID() iotago.BlockID

func (*TestEnvironment) LastMilestoneID

func (te *TestEnvironment) LastMilestoneID() iotago.MilestoneID

func (*TestEnvironment) LastMilestoneIndex

func (te *TestEnvironment) LastMilestoneIndex() iotago.MilestoneIndex

func (*TestEnvironment) LastMilestoneParents

func (te *TestEnvironment) LastMilestoneParents() iotago.BlockIDs

func (*TestEnvironment) LastMilestonePayload

func (te *TestEnvironment) LastMilestonePayload() *iotago.Milestone

func (*TestEnvironment) LastPreviousMilestoneID

func (te *TestEnvironment) LastPreviousMilestoneID() iotago.MilestoneID

func (*TestEnvironment) NewBlockBuilder

func (te *TestEnvironment) NewBlockBuilder(optionalTag ...string) *BlockBuilder

func (*TestEnvironment) NewTestBlock

func (te *TestEnvironment) NewTestBlock(index int, parents iotago.BlockIDs) *storage.BlockMetadata

func (*TestEnvironment) PerformWhiteFlagConfirmation

func (te *TestEnvironment) PerformWhiteFlagConfirmation(milestonePayload *iotago.Milestone) (*whiteflag.Confirmation, *whiteflag.ConfirmedMilestoneStats, error)

func (*TestEnvironment) ProtocolManager

func (te *TestEnvironment) ProtocolManager() *protocol.Manager

func (*TestEnvironment) ProtocolParameters

func (te *TestEnvironment) ProtocolParameters() *iotago.ProtocolParameters

func (*TestEnvironment) ReattachBlock

func (te *TestEnvironment) ReattachBlock(blockID iotago.BlockID, parents ...iotago.BlockID) iotago.BlockID

func (*TestEnvironment) Storage

func (te *TestEnvironment) Storage() *storage.Storage

func (*TestEnvironment) StoreBlock

func (te *TestEnvironment) StoreBlock(block *storage.Block) *storage.CachedBlock

StoreBlock adds the block to the storage layer and solidifies it. block +1.

func (*TestEnvironment) SyncManager

func (te *TestEnvironment) SyncManager() *syncmanager.SyncManager

func (*TestEnvironment) UTXOManager

func (te *TestEnvironment) UTXOManager() *utxo.Manager

func (*TestEnvironment) UnspentAddressOutputsWithoutConstraints

func (te *TestEnvironment) UnspentAddressOutputsWithoutConstraints(address iotago.Address, options ...utxo.IterateOption) (utxo.Outputs, error)

func (*TestEnvironment) UnspentAliasOutputsInLedger

func (te *TestEnvironment) UnspentAliasOutputsInLedger() utxo.Outputs

func (*TestEnvironment) UnspentFoundryOutputsInLedger

func (te *TestEnvironment) UnspentFoundryOutputsInLedger() utxo.Outputs

func (*TestEnvironment) UnspentNFTOutputsInLedger

func (te *TestEnvironment) UnspentNFTOutputsInLedger() utxo.Outputs

func (*TestEnvironment) VerifyCMI

func (te *TestEnvironment) VerifyCMI(index iotago.MilestoneIndex)

VerifyCMI checks if the confirmed milestone index is equal to the given milestone index.

func (*TestEnvironment) VerifyLMI

func (te *TestEnvironment) VerifyLMI(index iotago.MilestoneIndex)

VerifyLMI checks if the latest milestone index is equal to the given milestone index.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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