scenario

package
v1.1.17 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoClients = errors.New("no clients available")
	ErrNoWallet  = errors.New("no wallet available")
)
View Source
var GlobalSlotDuration time.Duration = 12 * time.Second

GlobalSlotDuration is the global setting for slot/block duration used in rate limiting. This can be set via CLI flag (--slot-duration) and applies to all scenarios. For L1 chains, this is typically 12s. For L2s like Arbitrum, it can be 250ms or less.

Functions

func GetScenarioValidFields added in v1.1.7

func GetScenarioValidFields(descriptor *Descriptor) map[string]FieldInfo

GetScenarioValidFields returns the valid fields for a scenario by extracting them from the scenario descriptor

func ParseAndValidateConfig added in v1.1.7

func ParseAndValidateConfig(descriptor *Descriptor, configYAML string, target interface{}, logger logrus.FieldLogger) error

ParseAndValidateConfig is a generalized helper that validates and parses YAML config for any scenario

func RunTransactionScenario

func RunTransactionScenario(ctx context.Context, options TransactionScenarioOptions) error

RunTransactionScenario executes a controlled transaction scenario with rate limiting and concurrency management. It processes transactions according to the specified options until either context cancellation or reaching TotalCount (if > 0).

Features: - Rate-limited execution based on Throughput - Optional dynamic throughput increases - Concurrency control via MaxPending - Sequential logging via transaction chaining

Returns an error only if the scenario cannot be started. Transaction failures should be handled within ProcessNextTxFn.

func ValidateScenarioConfig added in v1.1.7

func ValidateScenarioConfig(descriptor *Descriptor, configYAML string, logger logrus.FieldLogger) error

ValidateScenarioConfig validates configuration for a scenario using reflection-based field extraction

Types

type Category added in v1.1.16

type Category struct {
	Name        string
	Description string
	Descriptors []*Descriptor
	Children    []*Category
}

Category describes the category of a scenario.

type ConfigValidator added in v1.1.7

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

ConfigValidator provides validation for scenario configurations

func NewConfigValidator added in v1.1.7

func NewConfigValidator(scenarioName string, validFields map[string]FieldInfo, logger logrus.FieldLogger) *ConfigValidator

NewConfigValidator creates a new configuration validator for a specific scenario

func (*ConfigValidator) ValidateConfig added in v1.1.7

func (cv *ConfigValidator) ValidateConfig(configYAML string) *ValidationResult

ValidateConfig validates a YAML configuration against the scenario's valid fields

type Descriptor

type Descriptor struct {
	Name           string
	Aliases        []string
	Description    string
	DefaultOptions any
	NewScenario    func(logger logrus.FieldLogger) Scenario
}

Descriptor describes a scenario.

type FieldInfo added in v1.1.7

type FieldInfo struct {
	Type         reflect.Type
	DefaultValue interface{}
	Description  string
}

FieldInfo contains metadata about a valid configuration field

type Options

type Options struct {
	WalletPool *spamoor.WalletPool
	Config     string
	GlobalCfg  map[string]any
}

Options contains the options for the scenario initialization.

type ProcessNextTxParams added in v1.1.10

type ProcessNextTxParams struct {
	TxIdx           uint64
	OrderedLogCb    func(logFunc func()) // Optional callback to log transaction results in order
	NotifySubmitted func()               // Optional callback to notify that the transaction has been submitted
}

type ReceiptChan added in v1.1.10

type ReceiptChan chan *types.Receipt

func (ReceiptChan) Wait added in v1.1.10

func (rc ReceiptChan) Wait(ctx context.Context) (*types.Receipt, error)

type Scenario

type Scenario interface {
	// Flags registers the scenario's flags with the given flag set.
	Flags(flags *pflag.FlagSet) error
	// Init initializes the scenario with the given options.
	Init(options *Options) error
	// Run runs the scenario.
	Run(ctx context.Context) error
}

type TransactionScenarioOptions

type TransactionScenarioOptions struct {
	TotalCount                  uint64
	Throughput                  uint64
	MaxPending                  uint64
	ThroughputIncrementInterval uint64
	Timeout                     time.Duration // Maximum duration for scenario execution (0 = no timeout)
	WalletPool                  *spamoor.WalletPool
	NoAwaitTransactions         bool // If true, the scenario will not wait for transactions to be included in a block

	// Logger for scenario execution information
	Logger *logrus.Entry

	// ProcessNextTxFn handles transaction execution with the given index
	// It should return:
	// - A callback function to log transaction results (can be nil)
	// - An error if transaction creation failed
	ProcessNextTxFn func(ctx context.Context, params *ProcessNextTxParams) error
}

TransactionScenarioOptions configures how the transaction scenario is executed.

type ValidationResult added in v1.1.7

type ValidationResult struct {
	Valid    bool
	Errors   []string
	Warnings []string
}

ValidationResult contains the results of configuration validation

Jump to

Keyboard shortcuts

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