generatetransaction

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

README

generate_transaction Task

Description

The generate_transaction task creates and sends a single transaction to the network and optionally checks the transaction receipt. This task is useful for testing specific transaction behaviors, including contract deployments, and verifying receipt properties like triggered events.

Configuration Parameters

  • privateKey:
    The private key used for generating the transaction.

  • legacyTxType:
    If true, generates a legacy (type 0) transaction. If false, a dynamic fee (type 2) transaction is created.

  • blobTxType:
    If true, generates a blob (type 3) transaction. Otherwise, a dynamic fee (type 2) transaction is used.

  • blobFeeCap:
    The fee cap for blob transactions. Used only if blobTxType is true.

  • feeCap:
    The maximum fee cap for the transaction.

  • tipCap:
    The tip cap for the transaction.

  • gasLimit:
    The gas limit for the transaction.

  • targetAddress:
    The target address for the transaction.

  • randomTarget:
    If true, the transaction is sent to a random address.

  • contractDeployment:
    If true, the transaction is for deploying a contract.

  • callData:
    Call data included in the transaction.

  • blobData:
    Data for the blob component of the transaction. Used only if blobTxType is true.

  • randomAmount:
    If true, the transaction amount is randomized.

  • amount:
    The amount of cryptocurrency to be sent in the transaction.

  • clientPattern:
    A regex pattern to select specific client endpoints for sending the transaction.

  • excludeClientPattern:
    A regex pattern to exclude certain clients from being used for sending the transaction.

  • awaitReceipt:
    If false, the task succeeds immediately after sending the transaction without waiting for the receipt. If true, it waits for the receipt.

  • failOnReject:
    If true, the task fails if the transaction is rejected.

  • failOnSuccess:
    If true, the task fails if the transaction is successful and not rejected.

  • expectEvents:
    A list of events that the transaction is expected to trigger, specified in a structured object format. Each event object can have the following properties: topic0, topic1, topic2, topic3, and data. All these properties are optional and expressed as hexadecimal strings (e.g., "0x000..."). The task checks all triggered events against these objects and looks for a match that satisfies all specified properties in any single event. An example event object might look like this:

    - { "topic0": "0x000...", "topic1": "0x000...", "topic2": "0x000...", "topic3": "0x000...", "data": "0x000..." }
    
  • transactionHashResultVar:
    The variable name to store the transaction hash, available for use by subsequent tasks.

  • transactionReceiptResultVar:
    The variable name to store the full transaction receipt, available for use by subsequent tasks.

  • contractAddressResultVar:
    The variable name to store the deployed contract address if the transaction was a contract deployment, available for use by subsequent tasks.

Defaults

Default settings for the generate_transaction task:

- name: generate_transaction
  config:
    privateKey: ""
    legacyTxType: false
    blobTxType: false
    blobFeeCap: null
    feeCap: "100000000000"
    tipCap: "1000000000"
    gasLimit: 50000
    targetAddress: ""
    randomTarget: false
    contractDeployment: false
    callData: ""
    blobData: ""
    randomAmount: false
    amount: "0"
    clientPattern: ""
    excludeClientPattern: ""
    awaitReceipt: true
    failOnReject: false
    failOnSuccess: false
    expectEvents: []
    transactionHashResultVar: ""
    transactionReceiptResultVar: ""
    contractAddressResultVar: ""

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TaskName       = "generate_transaction"
	TaskDescriptor = &types.TaskDescriptor{
		Name:        TaskName,
		Description: "Generates normal transaction, sends it to the network and checks the receipt",
		Config:      DefaultConfig(),
		NewTask:     NewTask,
	}
)

Functions

func NewTask

func NewTask(ctx *types.TaskContext, options *types.TaskOptions) (types.Task, error)

Types

type Config

type Config struct {
	PrivateKey string `yaml:"privateKey" json:"privateKey"`

	LegacyTxType       bool     `yaml:"legacyTxType" json:"legacyTxType"`
	BlobTxType         bool     `yaml:"blobTxType" json:"blobTxType"`
	BlobFeeCap         *big.Int `yaml:"blobFeeCap" json:"blobFeeCap"`
	FeeCap             *big.Int `yaml:"feeCap" json:"feeCap"`
	TipCap             *big.Int `yaml:"tipCap" json:"tipCap"`
	GasLimit           uint64   `yaml:"gasLimit" json:"gasLimit"`
	TargetAddress      string   `yaml:"targetAddress" json:"targetAddress"`
	RandomTarget       bool     `yaml:"randomTarget" json:"randomTarget"`
	ContractDeployment bool     `yaml:"contractDeployment" json:"contractDeployment"`
	CallData           string   `yaml:"callData" json:"callData"`
	BlobData           string   `yaml:"blobData" json:"blobData"`
	RandomAmount       bool     `yaml:"randomAmount" json:"randomAmount"`
	Amount             *big.Int `yaml:"amount" json:"amount"`

	ClientPattern        string `yaml:"clientPattern" json:"clientPattern"`
	ExcludeClientPattern string `yaml:"excludeClientPattern" json:"excludeClientPattern"`

	AwaitReceipt  bool `yaml:"awaitReceipt" json:"awaitReceipt"`
	FailOnReject  bool `yaml:"failOnReject" json:"failOnReject"`
	FailOnSuccess bool `yaml:"failOnSuccess" json:"failOnSuccess"`
	ExpectEvents  []struct {
		Topic0 string `yaml:"topic0" json:"topic0"`
		Topic1 string `yaml:"topic1" json:"topic1"`
		Topic2 string `yaml:"topic2" json:"topic2"`
		Data   string `yaml:"data" json:"data"`
	} `yaml:"expectEvents" json:"expectEvents"`

	TransactionHashResultVar    string `yaml:"transactionHashResultVar" json:"transactionHashResultVar"`
	TransactionReceiptResultVar string `yaml:"transactionReceiptResultVar" json:"transactionReceiptResultVar"`
	ContractAddressResultVar    string `yaml:"contractAddressResultVar" json:"contractAddressResultVar"`
}

func DefaultConfig

func DefaultConfig() Config

func (*Config) Validate

func (c *Config) Validate() error

type Task

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

func (*Task) Config

func (t *Task) Config() interface{}

func (*Task) Description

func (t *Task) Description() string

func (*Task) Execute

func (t *Task) Execute(ctx context.Context) error

func (*Task) LoadConfig

func (t *Task) LoadConfig() error

func (*Task) Logger

func (t *Task) Logger() logrus.FieldLogger

func (*Task) Name

func (t *Task) Name() string

func (*Task) Timeout

func (t *Task) Timeout() time.Duration

func (*Task) Title

func (t *Task) Title() string

Jump to

Keyboard shortcuts

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