checkethcall

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2025 License: GPL-3.0 Imports: 10 Imported by: 0

README

check_eth_call Task

Description

The check_eth_call task verifies the response from an eth_call transaction on the Ethereum blockchain. This task is essential for validating contract interactions that do not require gas or change the state of the blockchain but need to be tested for expected outcomes.

Configuration Parameters

  • ethCallData: The data to be sent in the eth_call transaction, encoded as a hex string. This typically includes the function signature and arguments for contract interactions.

  • expectResult: The expected result of the eth_call transaction, expressed as a hex string. This is the value that the call is expected to return under normal circumstances and makes the task succeed.

  • ignoreResults: An array of results that, if returned from the eth_call, should be ignored. This allows the task to be flexible by acknowledging and skipping known but irrelevant results.

  • callAddress: The contract address targeted by the eth_call. This should be the address of the contract whose methods are being invoked.

  • blockNumber: Specifies the block number at which the state should be queried. A value of 0 typically indicates the latest block.

  • failOnMismatch: Determines whether the task should fail if the result of the eth_call does not match the expectResult and is not in the list of ignoreResults. If set to false, the task will not fail on a result mismatch, allowing further actions or checks to proceed.

  • clientPattern: A regex pattern to select specific client endpoints for sending the eth_call. This allows targeting of appropriate nodes within the network.

  • excludeClientPattern: A regex pattern to exclude certain clients from being used to make the eth_call, optimizing the selection of nodes based on the test scenario.

Outputs

  • callResult: The result of the eth_call transaction, returned as a hex string. This output provides direct feedback from the contract method being invoked and is crucial for verifying the result with custom logic.

Defaults

Default settings for the check_eth_call task:

- name: check_eth_call
  config:
    ethCallData: "0x"
    expectResult: ""
    ignoreResults: []
    callAddress: "0x0000000000000000000000000000000000000000"
    blockNumber: 0
    failOnMismatch: false
    clientPattern: ""
    excludeClientPattern: ""

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TaskName       = "check_eth_call"
	TaskDescriptor = &types.TaskDescriptor{
		Name:        TaskName,
		Description: "Checks the response of an eth_call transaction",
		Config:      DefaultConfig(),
		NewTask:     NewTask,
	}
)

Functions

func NewTask

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

Types

type Config

type Config struct {
	EthCallData    string   `yaml:"ethCallData" json:"ethCallData"`
	ExpectResult   string   `yaml:"expectResult" json:"expectResult"`
	IgnoreResults  []string `yaml:"ignoreResults" json:"ignoreResults"`
	CallAddress    string   `yaml:"callAddress" json:"callAddress"`
	BlockNumber    uint64   `yaml:"blockNumber" json:"blockNumber"`
	FailOnMismatch bool     `yaml:"failOnMismatch" json:"failOnMismatch"`

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

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) Execute

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

func (*Task) LoadConfig

func (t *Task) LoadConfig() error

func (*Task) Timeout

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

Jump to

Keyboard shortcuts

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