txgen

package
v0.0.0-...-6b63afb Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTxGenerators = []GenerateTx{GenTransfer, GenNonce}

DefaultTxGenerators is the default set of transaction generators, which can be used as the txGens argument to Generate().

Functions

func CheckInvariants

func CheckInvariants(ctx context.Context, rtc client.RuntimeClient) error

CheckInvariants issues a check of invariants in all modules in the runtime.

func CreateAndFundAccount

func CreateAndFundAccount(ctx context.Context, rtc client.RuntimeClient, funder signature.Signer, id int, acctType AccountType, fundAmount uint64) (signature.Signer, error)

CreateAndFundAccount creates a new account and funds it using the given funding account.

func EstimateGas

func EstimateGas(ctx context.Context, rtc client.RuntimeClient, tx types.Transaction, extraGas uint64) types.Transaction

EstimateGas estimates the amount of gas the transaction will use. Returns modified transaction that has just the right amount of gas.

func GenNonce

GenNonce just queries the account's nonce.

func GenTransfer

func GenTransfer(
	ctx context.Context,
	rtc client.RuntimeClient,
	rng *rand.Rand,
	acct signature.Signer,
	accts []signature.Signer,
) (*types.Transaction, error)

GenTransfer generates transfer transactions.

func Generate

func Generate(ctx context.Context, rtc client.RuntimeClient, rng *rand.Rand, accounts []signature.Signer, txGens []GenerateTx, txDelay time.Duration) (uint64, uint64, uint64, error)

Generate generates and submits a random transaction for the given accounts every txDelay seconds until the context is terminated.

func GetChainContext

func GetChainContext(ctx context.Context, rtc client.RuntimeClient) (signature.Context, error)

GetChainContext returns the chain context.

func NewClient

func NewClient(clientNodeUnixSocketPath string, runtimeID common.Namespace) (client.RuntimeClient, error)

NewClient creates a new runtime client.

func RandomizeFee

func RandomizeFee(_ context.Context, rng *rand.Rand, tx *types.Transaction) error

RandomizeFee generates random fee parameters for the transaction.

func SignAndSubmitTxRaw

func SignAndSubmitTxRaw(ctx context.Context, rtc client.RuntimeClient, signer signature.Signer, tx types.Transaction, extraGas uint64) (*types.CallResult, error)

SignAndSubmitTxRaw signs and submits the given transaction. Gas estimation is done automatically.

Types

type AccountType

type AccountType uint8

AccountType is the type of account to create.

const (
	AccountEd25519   AccountType = 0
	AccountSecp256k1 AccountType = 1
	AccountSr25519   AccountType = 2
	AccountTypeMax               = AccountSr25519
)

Supported account types.

func (AccountType) String

func (at AccountType) String() string

type GenerateTx

GenerateTx is a function that generates a random transaction or performs a random query (in which case the returned transaction can be nil).

Jump to

Keyboard shortcuts

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