tests

package
v1.0.0-alpha.13 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CastVotes

func CastVotes(t *testing.T, tf *Framework)

func CastVotesAcceptance

func CastVotesAcceptance(t *testing.T, tf *Framework)

func CastVotesVoteRank

func CastVotesVoteRank(t *testing.T, tf *Framework)

func CreateSpendWithoutMembers

func CreateSpendWithoutMembers(t *testing.T, tf *Framework)

func CreateSpender

func CreateSpender(t *testing.T, tf *Framework)

func EvictAcceptedSpender

func EvictAcceptedSpender(t *testing.T, tf *Framework)

func EvictRejectedSpender

func EvictRejectedSpender(t *testing.T, tf *Framework)

func ExistingSpenderJoinsSpendSets

func ExistingSpenderJoinsSpendSets(t *testing.T, tf *Framework)

func JoinSpendSetTwice

func JoinSpendSetTwice(t *testing.T, tf *Framework)

func LikedInstead

func LikedInstead(t *testing.T, tf *Framework)

func SpendAcceptance

func SpendAcceptance(t *testing.T, tf *Framework)

func TestAll

func TestAll(t *testing.T, frameworkProvider func(*testing.T) *Framework)

func UpdateSpenderParents

func UpdateSpenderParents(t *testing.T, tf *Framework)

Types

type AccountsTestFramework

type AccountsTestFramework struct {
	Instance  *account.Accounts
	Committee *account.SeatedAccounts
	// contains filtered or unexported fields
}

func NewAccountsTestFramework

func NewAccountsTestFramework(t *testing.T, instance *account.Accounts) *AccountsTestFramework

func (*AccountsTestFramework) Add

func (f *AccountsTestFramework) Add(alias string)

func (*AccountsTestFramework) CreateID

func (f *AccountsTestFramework) CreateID(alias string) iotago.AccountID

func (*AccountsTestFramework) Delete

func (f *AccountsTestFramework) Delete(alias string) bool

func (*AccountsTestFramework) Get

func (f *AccountsTestFramework) Get(alias string) (seat account.SeatIndex, exists bool)

func (*AccountsTestFramework) Has

func (f *AccountsTestFramework) Has(alias string) bool

func (*AccountsTestFramework) ID

type Assertions

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

Assertions provides a set of assertions for the SpendDAG.

func (*Assertions) Accepted

func (a *Assertions) Accepted(aliases ...string)

Accepted asserts that the given spenders are accepted.

func (*Assertions) Children

func (a *Assertions) Children(spendAlias string, childAliases ...string)

Children asserts that the given spender has the given children.

func (*Assertions) LikedInstead

func (a *Assertions) LikedInstead(spendAliases []string, likedInsteadAliases ...string)

LikedInstead asserts that the given spenders return the given LikedInstead spenders.

func (*Assertions) Parents

func (a *Assertions) Parents(spendAlias string, parentAliases ...string)

Parents asserts that the given spend has the given parents.

func (*Assertions) Pending

func (a *Assertions) Pending(aliases ...string)

Pending asserts that the given spenders are pending.

func (*Assertions) Rejected

func (a *Assertions) Rejected(aliases ...string)

Rejected asserts that the given spenders are rejected.

func (*Assertions) SpendSetMembers

func (a *Assertions) SpendSetMembers(resourceAlias string, spendAliases ...string)

SpendSetMembers asserts that the given resource has the given spend set members.

func (*Assertions) SpendSets

func (a *Assertions) SpendSets(spenderAlias string, resourceAliases ...string)

SpendSets asserts that the given spender has the given spend sets.

func (*Assertions) ValidatorWeight

func (a *Assertions) ValidatorWeight(spendAlias string, weight int64)

ValidatorWeight asserts that the given spend has the given validator weight.

type Framework

type Framework struct {
	// Instance is the SpendDAG instance that is used in the tests.
	Instance spenddag.SpendDAG[iotago.TransactionID, iotago.OutputID, vote.MockedRank]

	// Accounts is the AccountsTestFramework that is used in the tests.
	Accounts *AccountsTestFramework

	// Assert provides a set of assertions that can be used to verify the state of the SpendDAG.
	Assert *Assertions

	// SpenderID is a function that is used to translate a string alias into a (deterministic) iotago.TransactionID.
	SpenderID func(string) iotago.TransactionID

	// ResourceID is a function that is used to translate a string alias into a (deterministic) iotago.OutputID.
	ResourceID func(string) iotago.OutputID
	// contains filtered or unexported fields
}

Framework is a test framework for the SpendDAG that allows to easily create and manipulate the DAG and its validators using human-readable aliases instead of actual IDs.

func NewFramework

func NewFramework(
	t *testing.T,
	spendDAG spenddag.SpendDAG[iotago.TransactionID, iotago.OutputID, vote.MockedRank],
	validators *AccountsTestFramework,
	spenderID func(string) iotago.TransactionID,
	resourceID func(string) iotago.OutputID,
) *Framework

NewFramework creates a new instance of the Framework.

func (*Framework) CastVotes

func (f *Framework) CastVotes(nodeAlias string, voteRank int, spenderAliases ...string) error

CastVotes casts the given votes for the given spenders.

func (*Framework) CreateOrUpdateSpender

func (f *Framework) CreateOrUpdateSpender(alias string, resourceAliases []string) error

CreateOrUpdateSpender creates a new spender or adds it to the given SpendSets.

func (*Framework) EvictSpender

func (f *Framework) EvictSpender(spendAlias string)

EvictSpender evicts given spender from the SpendDAG.

func (*Framework) LikedInstead

func (f *Framework) LikedInstead(spendAliases ...string) ds.Set[iotago.TransactionID]

LikedInstead returns the set of spenders that are liked instead of the given spenders.

func (*Framework) SpendSetIDs

func (f *Framework) SpendSetIDs(aliases ...string) ds.Set[iotago.OutputID]

SpendSetIDs translates the given aliases into an AdvancedSet of iotago.OutputIDs.

func (*Framework) SpenderIDs

func (f *Framework) SpenderIDs(aliases ...string) ds.Set[iotago.TransactionID]

SpenderIDs translates the given aliases into an AdvancedSet of iotago.TransactionIDs.

func (*Framework) UpdateSpenderParents

func (f *Framework) UpdateSpenderParents(spendAlias string, addedParentIDs []string, removedParentIDs []string) error

UpdateSpenderParents updates the parents of the spender with the given alias.

Jump to

Keyboard shortcuts

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