actions

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KeyNumberOfTestUsers = ActionKey("numberOfTestUsers")

KeyNumberOfTestUsers key to an int representing number of test users created/available (useful for test actions that want to run for all users without having to duplicate config)

View Source
var (
	// SnapAfterAllocation used to record state after initialisation and faucet allocations to test users
	SnapAfterAllocation = "after-allocation"
)

standard snapshots to use as reference points across all tests

Functions

func FetchBalanceAtSnapshot

func FetchBalanceAtSnapshot(ctx context.Context, userID int, snapshot string) (*big.Int, error)

func FetchBigInt

func FetchBigInt(ctx context.Context, key ActionKey) (*big.Int, error)

func FetchNumberOfTestUsers

func FetchNumberOfTestUsers(ctx context.Context) (int, error)

func FetchTestUser

func FetchTestUser(ctx context.Context, userNumber int) (userwallet.User, error)

func GenerateUsersRandomisedTransferActionsInParallel

func GenerateUsersRandomisedTransferActionsInParallel(txPerSec int, duration time.Duration) networktest.Action

func RandomSleepAction

func RandomSleepAction(minSleep time.Duration, maxSleep time.Duration) networktest.Action

func RunOnlyAction

func RunOnlyAction(run RunFunc) networktest.Action

RunOnlyAction allows you to create an action quickly with an in-line function when it doesn't need state or a verify method

func SetContextValue

func SetContextValue(key ActionKey, value interface{}) networktest.Action

SetContextValue is a simple action step that just sets a value on the context

func SleepAction

func SleepAction(duration time.Duration) networktest.Action

func SnapshotUserBalances

func SnapshotUserBalances(snapshot string) networktest.Action

SnapshotUserBalances requests and records the curr users native balances in the context Note: when running this ensure that there are no transactions in flight if that will affect usage of this data

func StartSequencerEnclave

func StartSequencerEnclave() networktest.Action

func StartSequencerHost

func StartSequencerHost() networktest.Action

func StartValidatorEnclave

func StartValidatorEnclave(validatorIdx int) networktest.Action

func StartValidatorHost

func StartValidatorHost(validatorIdx int) networktest.Action

func StopSequencerEnclave

func StopSequencerEnclave() networktest.Action

func StopSequencerHost

func StopSequencerHost() networktest.Action

func StopValidatorEnclave

func StopValidatorEnclave(validatorIdx int) networktest.Action

func StopValidatorHost

func StopValidatorHost(validatorIdx int) networktest.Action

func VerifyOnlyAction

func VerifyOnlyAction(verify VerifyFunc) networktest.Action

VerifyOnlyAction allows you to create a test verification quickly with an in-line function when it doesn't need state or a run method

func VerifyUserBalancesSanity

func VerifyUserBalancesSanity() networktest.Action

VerifyUserBalancesSanity expects a balances SnapAfterAllocation snapshot It sums up the user balances then and now to make sure that the total hasn't increased and that it's decreased but not drastically (gas fees)

func WaitForSequencerHealthCheck

func WaitForSequencerHealthCheck(maxWait time.Duration) networktest.Action

func WaitForValidatorHealthCheck

func WaitForValidatorHealthCheck(validatorIdx int, maxWait time.Duration) networktest.Action

Types

type ActionKey

type ActionKey string

ActionKey is the type for all test data stored in the context. Go documentation recommends using a typed key rather than string to avoid conflicts.

func BalanceSnapshotKey

func BalanceSnapshotKey(userID int, snapshot string) ActionKey

type AllocateFaucetFunds

type AllocateFaucetFunds struct {
	UserID  int
	Account *common.Address
}

AllocateFaucetFunds is an action that allocates funds from the network faucet to a user, either UserID or Account must be set (not both) to fund a test user or a specific account respectively

func (*AllocateFaucetFunds) Run

func (*AllocateFaucetFunds) String

func (a *AllocateFaucetFunds) String() string

func (*AllocateFaucetFunds) Verify

type CreateTestUser

type CreateTestUser struct {
	UserID     int
	UseGateway bool
}

func (*CreateTestUser) Run

func (*CreateTestUser) String

func (c *CreateTestUser) String() string

func (*CreateTestUser) Verify

type MultiAction

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

func CreateAndFundTestUsers

func CreateAndFundTestUsers(numUsers int) *MultiAction

func NamedParallel

func NamedParallel(name string, actions ...networktest.Action) *MultiAction

func NamedSeries

func NamedSeries(name string, actions ...networktest.Action) *MultiAction

func Parallel

func Parallel(actions ...networktest.Action) *MultiAction

func Series

func Series(actions ...networktest.Action) *MultiAction

func (*MultiAction) Run

func (*MultiAction) String

func (m *MultiAction) String() string

func (*MultiAction) Verify

func (m *MultiAction) Verify(ctx context.Context, network networktest.NetworkConnector) error

type RunFunc

type RunFunc func(ctx context.Context, network networktest.NetworkConnector) (context.Context, error)

type SendNativeFunds

type SendNativeFunds struct {
	FromUser   int
	ToUser     int
	Amount     *big.Int
	GasLimit   *big.Int
	SkipVerify bool
	// contains filtered or unexported fields
}

func (*SendNativeFunds) Run

func (*SendNativeFunds) String

func (s *SendNativeFunds) String() string

func (*SendNativeFunds) Verify

type VerifyBalanceAfterTest

type VerifyBalanceAfterTest struct {
	UserID          int
	ExpectedBalance *big.Int
}

func (*VerifyBalanceAfterTest) Run

func (*VerifyBalanceAfterTest) String

func (c *VerifyBalanceAfterTest) String() string

func (*VerifyBalanceAfterTest) Verify

type VerifyBalanceDiffAfterTest

type VerifyBalanceDiffAfterTest struct {
	UserID       int
	ExpectedDiff *big.Int
	Snapshot     string
}

VerifyBalanceDiffAfterTest compares the post-test user balance with the balance at the given snapshot

This only checks the balance against an upper bound because of unknown gas spend, it expects `currBal < snapshotBal + expectedDiff`

func (*VerifyBalanceDiffAfterTest) Run

func (*VerifyBalanceDiffAfterTest) Verify

type VerifyFunc

type VerifyFunc func(ctx context.Context, network networktest.NetworkConnector) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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