Documentation ¶
Overview ¶
Package blockchain handles connections to various blockchains
Index ¶
- Constants
- Variables
- func LogRevertReason(err error, abiString string) error
- type ArbitrumClient
- type ArbitrumMultinodeClient
- type ContractDeployer
- type EVMClient
- type EVMNetwork
- type EthereumClient
- func (e *EthereumClient) AddHeaderEventSubscription(key string, subscriber HeaderEventSubscription)
- func (e *EthereumClient) BalanceAt(ctx context.Context, address common.Address) (*big.Int, error)
- func (e *EthereumClient) BorrowedNonces(n bool)
- func (e *EthereumClient) Close() error
- func (e *EthereumClient) DeleteHeaderEventSubscription(key string)
- func (e *EthereumClient) DeployContract(contractName string, deployer ContractDeployer) (*common.Address, *types.Transaction, interface{}, error)
- func (e *EthereumClient) EstimateCostForChainlinkOperations(amountOfOperations int) (*big.Float, error)
- func (e *EthereumClient) EstimateTransactionGasCost() (*big.Int, error)
- func (e *EthereumClient) Fund(toAddress string, amount *big.Float) error
- func (e *EthereumClient) GasStats() *GasStats
- func (e *EthereumClient) Get() interface{}
- func (e *EthereumClient) GetChainID() *big.Int
- func (e *EthereumClient) GetClients() []EVMClient
- func (e *EthereumClient) GetDefaultWallet() *EthereumWallet
- func (e *EthereumClient) GetHeaderSubscriptions() map[string]HeaderEventSubscription
- func (e *EthereumClient) GetNetworkConfig() *EVMNetwork
- func (e *EthereumClient) GetNetworkName() string
- func (e *EthereumClient) GetNonce(ctx context.Context, addr common.Address) (uint64, error)
- func (e *EthereumClient) GetTxReceipt(txHash common.Hash) (*types.Receipt, error)
- func (e *EthereumClient) GetWallets() []*EthereumWallet
- func (e *EthereumClient) HeaderHashByNumber(ctx context.Context, bn *big.Int) (string, error)
- func (e *EthereumClient) HeaderTimestampByNumber(ctx context.Context, bn *big.Int) (uint64, error)
- func (e *EthereumClient) IsEventConfirmed(event *types.Log) (confirmed, removed bool, err error)
- func (e *EthereumClient) IsTxConfirmed(txHash common.Hash) (bool, error)
- func (e *EthereumClient) LatestBlockNumber(ctx context.Context) (uint64, error)
- func (e *EthereumClient) LoadWallets(cfg interface{}) error
- func (e *EthereumClient) NetworkSimulated() bool
- func (e *EthereumClient) ParallelTransactions(enabled bool)
- func (e *EthereumClient) ProcessEvent(name string, event *types.Log, confirmedChan chan bool, errorChan chan error) error
- func (e *EthereumClient) ProcessTransaction(tx *types.Transaction) error
- func (e *EthereumClient) SetDefaultWallet(num int) error
- func (e *EthereumClient) SetID(id int)
- func (e *EthereumClient) SetWallets(wallets []*EthereumWallet)
- func (e *EthereumClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
- func (e *EthereumClient) SwitchNode(_ int) error
- func (e *EthereumClient) TransactionOpts(from *EthereumWallet) (*bind.TransactOpts, error)
- func (e *EthereumClient) WaitForEvents() error
- type EthereumMultinodeClient
- func (e *EthereumMultinodeClient) AddHeaderEventSubscription(key string, subscriber HeaderEventSubscription)
- func (e *EthereumMultinodeClient) BalanceAt(ctx context.Context, address common.Address) (*big.Int, error)
- func (e *EthereumMultinodeClient) Close() error
- func (e *EthereumMultinodeClient) DeleteHeaderEventSubscription(key string)
- func (e *EthereumMultinodeClient) DeployContract(contractName string, deployer ContractDeployer) (*common.Address, *types.Transaction, interface{}, error)
- func (e *EthereumMultinodeClient) EstimateCostForChainlinkOperations(amountOfOperations int) (*big.Float, error)
- func (e *EthereumMultinodeClient) EstimateTransactionGasCost() (*big.Int, error)
- func (e *EthereumMultinodeClient) Fund(toAddress string, nativeAmount *big.Float) error
- func (e *EthereumMultinodeClient) GasStats() *GasStats
- func (e *EthereumMultinodeClient) Get() interface{}
- func (e *EthereumMultinodeClient) GetChainID() *big.Int
- func (e *EthereumMultinodeClient) GetClients() []EVMClient
- func (e *EthereumMultinodeClient) GetDefaultWallet() *EthereumWallet
- func (e *EthereumMultinodeClient) GetNetworkConfig() *EVMNetwork
- func (e *EthereumMultinodeClient) GetNetworkName() string
- func (e *EthereumMultinodeClient) GetTxReceipt(txHash common.Hash) (*types.Receipt, error)
- func (e *EthereumMultinodeClient) GetWallets() []*EthereumWallet
- func (e *EthereumMultinodeClient) HeaderHashByNumber(ctx context.Context, bn *big.Int) (string, error)
- func (e *EthereumMultinodeClient) HeaderTimestampByNumber(ctx context.Context, bn *big.Int) (uint64, error)
- func (e *EthereumMultinodeClient) IsEventConfirmed(event *types.Log) (confirmed, removed bool, err error)
- func (e *EthereumMultinodeClient) IsTxConfirmed(txHash common.Hash) (bool, error)
- func (e *EthereumMultinodeClient) LatestBlockNumber(ctx context.Context) (uint64, error)
- func (e *EthereumMultinodeClient) LoadWallets(cfg interface{}) error
- func (e *EthereumMultinodeClient) NetworkSimulated() bool
- func (e *EthereumMultinodeClient) ParallelTransactions(enabled bool)
- func (e *EthereumMultinodeClient) ProcessEvent(name string, event *types.Log, confirmedChan chan bool, errorChan chan error) error
- func (e *EthereumMultinodeClient) ProcessTransaction(tx *types.Transaction) error
- func (e *EthereumMultinodeClient) SetDefaultWallet(num int) error
- func (e *EthereumMultinodeClient) SetID(id int)
- func (e *EthereumMultinodeClient) SetWallets(wallets []*EthereumWallet)
- func (e *EthereumMultinodeClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, logs chan<- types.Log) (ethereum.Subscription, error)
- func (e *EthereumMultinodeClient) SwitchNode(clientID int) error
- func (e *EthereumMultinodeClient) TransactionOpts(from *EthereumWallet) (*bind.TransactOpts, error)
- func (e *EthereumMultinodeClient) WaitForEvents() error
- type EthereumWallet
- type EventConfirmer
- type GasStats
- type HeaderEventSubscription
- type InstantConfirmer
- type KlaytnClient
- type KlaytnMultinodeClient
- type MetisClient
- type MetisMultinodeClient
- type NodeHeader
- type OptimismClient
- type OptimismMultinodeClient
- type PolygonEdgeClient
- type PolygonEdgeMultinodeClient
- type TXGasData
- type TransactionConfirmer
Constants ¶
const ( // GWei one giga-wei used for gas calculations GWei = 1e9 // ETH one eth in wei ETH = 1e18 )
Variables ¶
var ( // SimulatedEVMNetwork ensures that the test will use a default simulated geth instance SimulatedEVMNetwork = &EVMNetwork{ Name: "Simulated Geth", Simulated: true, ChainID: 1337, PrivateKeys: []string{ "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", "59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d", "5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a", }, ChainlinkTransactionLimit: 500000, Timeout: 2 * time.Minute, MinimumConfirmations: 1, GasEstimationBuffer: 10000, } )
Functions ¶
func LogRevertReason ¶ added in v1.6.0
LogRevertReason prints the revert reason for the transaction error by parsing through abi defined error list
Types ¶
type ArbitrumClient ¶ added in v1.5.3
type ArbitrumClient struct {
*EthereumClient
}
ArbitrumClient represents a single node, EVM compatible client for the Arbitrum network
type ArbitrumMultinodeClient ¶ added in v1.5.3
type ArbitrumMultinodeClient struct {
*EthereumMultinodeClient
}
ArbitrumMultinodeClient represents a multi-node, EVM compatible client for the Arbitrum network
type ContractDeployer ¶
type ContractDeployer func(auth *bind.TransactOpts, backend bind.ContractBackend) ( common.Address, *types.Transaction, interface{}, error, )
ContractDeployer acts as a go-between function for general contract deployment
type EVMClient ¶
type EVMClient interface { // Getters Get() interface{} GetNetworkName() string NetworkSimulated() bool GetChainID() *big.Int GetClients() []EVMClient GetDefaultWallet() *EthereumWallet GetWallets() []*EthereumWallet GetNetworkConfig() *EVMNetwork // Setters SetID(id int) SetDefaultWallet(num int) error SetWallets([]*EthereumWallet) LoadWallets(ns interface{}) error SwitchNode(node int) error // On-chain Operations BalanceAt(ctx context.Context, address common.Address) (*big.Int, error) HeaderHashByNumber(ctx context.Context, bn *big.Int) (string, error) HeaderTimestampByNumber(ctx context.Context, bn *big.Int) (uint64, error) LatestBlockNumber(ctx context.Context) (uint64, error) Fund(toAddress string, amount *big.Float) error DeployContract( contractName string, deployer ContractDeployer, ) (*common.Address, *types.Transaction, interface{}, error) TransactionOpts(from *EthereumWallet) (*bind.TransactOpts, error) ProcessTransaction(tx *types.Transaction) error ProcessEvent(name string, event *types.Log, confirmedChan chan bool, errorChan chan error) error IsEventConfirmed(event *types.Log) (confirmed, removed bool, err error) IsTxConfirmed(txHash common.Hash) (bool, error) GetTxReceipt(txHash common.Hash) (*types.Receipt, error) ParallelTransactions(enabled bool) Close() error // Gas Operations EstimateCostForChainlinkOperations(amountOfOperations int) (*big.Float, error) EstimateTransactionGasCost() (*big.Int, error) GasStats() *GasStats // Event Subscriptions AddHeaderEventSubscription(key string, subscriber HeaderEventSubscription) DeleteHeaderEventSubscription(key string) WaitForEvents() error SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) }
EVMClient is the interface that wraps a given client implementation for a blockchain, to allow for switching of network types within the test suite EVMClient can be connected to a single or multiple nodes,
func NewEVMClient ¶ added in v1.5.0
func NewEVMClient(networkSettings *EVMNetwork, env *environment.Environment) (EVMClient, error)
NewEVMClient returns a multi-node EVM client connected to the specified network
type EVMNetwork ¶ added in v1.4.0
type EVMNetwork struct { // Human-readable name of the network: Name string `envconfig:"evm_name" default:"Unnamed EVM Network" toml:"name"` // Chain ID for the blockchain ChainID int64 `envconfig:"evm_chain_id" default:"1337" toml:"chain_id"` // List of websocket URLs you want to connect to URLs []string `envconfig:"evm_urls" default:"ws://example.url" toml:"ws_urls"` // List of websocket URLs you want to connect to HTTPURLs []string `envconfig:"evm_http_urls" default:"http://example.url" toml:"http_urls"` // True if the network is simulated like a geth instance in dev mode. False if the network is a real test or mainnet Simulated bool `envconfig:"evm_simulated" default:"false" toml:"simulated"` // List of private keys to fund the tests PrivateKeys []string `envconfig:"evm_private_keys" default:"examplePrivateKey" toml:"private_keys"` // Default gas limit to assume that Chainlink nodes will use. Used to try to estimate the funds that Chainlink // nodes require to run the tests. ChainlinkTransactionLimit uint64 `envconfig:"evm_chainlink_transaction_limit" default:"500000" toml:"chainlink_transaction_limit"` // How long to wait for on-chain operations before timing out an on-chain operation Timeout time.Duration `envconfig:"evm_transaction_timeout" default:"2m" toml:"transaction_timeout"` // How many block confirmations to wait to confirm on-chain events MinimumConfirmations int `envconfig:"evm_minimum_confirmations" default:"1" toml:"minimum_confirmations"` // How much WEI to add to gas estimations for sending transactions GasEstimationBuffer uint64 `envconfig:"evm_gas_estimation_buffer" default:"1000" toml:"gas_estimation_buffer"` // Only used internally, do not set URL string `ignored:"true"` }
EVMNetwork configures all the data the test needs to connect and operate on an EVM compatible network
func LoadNetworkFromEnvironment ¶ added in v1.4.0
func LoadNetworkFromEnvironment() *EVMNetwork
LoadNetworkFromEnvironment loads an EVM network from default environment variables. Helpful in soak tests
func (*EVMNetwork) ChainlinkValuesMap ¶ added in v1.4.1
func (e *EVMNetwork) ChainlinkValuesMap() map[string]interface{}
ChainlinkValuesMap is a convenience function that marshalls the Chain ID and Chain URL into Chainlink Env var viable map
func (*EVMNetwork) ToMap ¶ added in v1.4.0
func (e *EVMNetwork) ToMap() map[string]interface{}
ToMap marshalls the network's values to a generic map, useful for setting env vars on instances like the remote runner Map Structure "envconfig_key": stringValue
type EthereumClient ¶
type EthereumClient struct { ID int Client *ethclient.Client NetworkConfig *EVMNetwork Wallets []*EthereumWallet DefaultWallet *EthereumWallet BorrowNonces bool NonceMu *sync.Mutex Nonces map[string]uint64 // contains filtered or unexported fields }
EthereumClient wraps the client and the BlockChain network to interact with an EVM based Blockchain
func (*EthereumClient) AddHeaderEventSubscription ¶
func (e *EthereumClient) AddHeaderEventSubscription(key string, subscriber HeaderEventSubscription)
AddHeaderEventSubscription adds a new header subscriber within the client to receive new headers
func (*EthereumClient) BalanceAt ¶ added in v1.2.3
BalanceAt returns the ETH balance of the specified address
func (*EthereumClient) BorrowedNonces ¶
func (e *EthereumClient) BorrowedNonces(n bool)
BorrowedNonces allows to handle nonces concurrently without requesting them every time
func (*EthereumClient) Close ¶
func (e *EthereumClient) Close() error
Close tears down the current open Ethereum client
func (*EthereumClient) DeleteHeaderEventSubscription ¶
func (e *EthereumClient) DeleteHeaderEventSubscription(key string)
DeleteHeaderEventSubscription removes a header subscriber from the map
func (*EthereumClient) DeployContract ¶
func (e *EthereumClient) DeployContract( contractName string, deployer ContractDeployer, ) (*common.Address, *types.Transaction, interface{}, error)
DeployContract acts as a general contract deployment tool to an ethereum chain
func (*EthereumClient) EstimateCostForChainlinkOperations ¶
func (e *EthereumClient) EstimateCostForChainlinkOperations(amountOfOperations int) (*big.Float, error)
EstimateCostForChainlinkOperations calculates required amount of ETH for amountOfOperations Chainlink operations based on the network's suggested gas price and the chainlink gas limit. This is fairly imperfect and should be used as only a rough, upper-end estimate instead of an exact calculation. See https://ethereum.org/en/developers/docs/gas/#post-london for info on how gas calculation works
func (*EthereumClient) EstimateTransactionGasCost ¶
func (e *EthereumClient) EstimateTransactionGasCost() (*big.Int, error)
EstimateTransactionGasCost estimates the current total gas cost for a simple transaction
func (*EthereumClient) Fund ¶
func (e *EthereumClient) Fund( toAddress string, amount *big.Float, ) error
Fund sends some ETH to an address using the default wallet
func (*EthereumClient) GasStats ¶
func (e *EthereumClient) GasStats() *GasStats
GasStats retrieves all information on gas spent by this client
func (*EthereumClient) Get ¶
func (e *EthereumClient) Get() interface{}
Get returns the underlying client type to be used generically across the framework for switching network types
func (*EthereumClient) GetChainID ¶
func (e *EthereumClient) GetChainID() *big.Int
GetChainID retrieves the ChainID of the network that the client interacts with
func (*EthereumClient) GetClients ¶
func (e *EthereumClient) GetClients() []EVMClient
GetClients not used, only applicable to EthereumMultinodeClient
func (*EthereumClient) GetDefaultWallet ¶
func (e *EthereumClient) GetDefaultWallet() *EthereumWallet
DefaultWallet returns the default wallet for the network
func (*EthereumClient) GetHeaderSubscriptions ¶
func (e *EthereumClient) GetHeaderSubscriptions() map[string]HeaderEventSubscription
GetHeaderSubscriptions returns a duplicate map of the queued transactions
func (*EthereumClient) GetNetworkConfig ¶
func (e *EthereumClient) GetNetworkConfig() *EVMNetwork
DefaultWallet returns the default wallet for the network
func (*EthereumClient) GetNetworkName ¶
func (e *EthereumClient) GetNetworkName() string
GetNetworkName retrieves the ID of the network that the client interacts with
func (*EthereumClient) GetNonce ¶
GetNonce keep tracking of nonces per address, add last nonce for addr if the map is empty
func (*EthereumClient) GetTxReceipt ¶ added in v1.2.4
GetTxReceipt returns the receipt of the transaction if available, error otherwise
func (*EthereumClient) GetWallets ¶
func (e *EthereumClient) GetWallets() []*EthereumWallet
DefaultWallet returns the default wallet for the network
func (*EthereumClient) HeaderHashByNumber ¶
HeaderHashByNumber gets header hash by block number
func (*EthereumClient) HeaderTimestampByNumber ¶
HeaderTimestampByNumber gets header timestamp by number
func (*EthereumClient) IsEventConfirmed ¶ added in v1.5.6
func (e *EthereumClient) IsEventConfirmed(event *types.Log) (confirmed, removed bool, err error)
IsEventConfirmed returns if eth client can confirm that the event happened
func (*EthereumClient) IsTxConfirmed ¶
func (e *EthereumClient) IsTxConfirmed(txHash common.Hash) (bool, error)
IsTxConfirmed checks if the transaction is confirmed on chain or not
func (*EthereumClient) LatestBlockNumber ¶
func (e *EthereumClient) LatestBlockNumber(ctx context.Context) (uint64, error)
BlockNumber gets latest block number
func (*EthereumClient) LoadWallets ¶
func (e *EthereumClient) LoadWallets(cfg interface{}) error
LoadWallets loads wallets from config
func (*EthereumClient) NetworkSimulated ¶ added in v1.4.0
func (e *EthereumClient) NetworkSimulated() bool
NetworkSimulated returns true if the network is a simulated geth instance, false otherwise
func (*EthereumClient) ParallelTransactions ¶
func (e *EthereumClient) ParallelTransactions(enabled bool)
ParallelTransactions when enabled, sends the transaction without waiting for transaction confirmations. The hashes are then stored within the client and confirmations can be waited on by calling WaitForEvents. When disabled, the minimum confirmations are waited on when the transaction is sent, so parallelisation is disabled.
func (*EthereumClient) ProcessEvent ¶ added in v1.5.6
func (e *EthereumClient) ProcessEvent(name string, event *types.Log, confirmedChan chan bool, errorChan chan error) error
ProcessTransaction will queue or wait on a transaction depending on whether parallel transactions are enabled
func (*EthereumClient) ProcessTransaction ¶
func (e *EthereumClient) ProcessTransaction(tx *types.Transaction) error
ProcessTransaction will queue or wait on a transaction depending on whether parallel transactions are enabled
func (*EthereumClient) SetDefaultWallet ¶
func (e *EthereumClient) SetDefaultWallet(num int) error
SetDefaultWallet sets default wallet
func (*EthereumClient) SetID ¶
func (e *EthereumClient) SetID(id int)
SetID sets client id, only used for multi-node networks
func (*EthereumClient) SetWallets ¶
func (e *EthereumClient) SetWallets(wallets []*EthereumWallet)
SetWallets sets all wallets to be used by the client
func (*EthereumClient) SubscribeFilterLogs ¶ added in v1.4.2
func (e *EthereumClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
SubscribeFilterLogs subscribes to the results of a streaming filter query.
func (*EthereumClient) SwitchNode ¶
func (e *EthereumClient) SwitchNode(_ int) error
SwitchNode not used, only applicable to EthereumMultinodeClient
func (*EthereumClient) TransactionOpts ¶
func (e *EthereumClient) TransactionOpts(from *EthereumWallet) (*bind.TransactOpts, error)
TransactionOpts returns the base Tx options for 'transactions' that interact with a smart contract. Since most contract interactions in this framework are designed to happen through abigen calls, it's intentionally quite bare.
func (*EthereumClient) WaitForEvents ¶
func (e *EthereumClient) WaitForEvents() error
WaitForEvents is a blocking function that waits for all event subscriptions that have been queued within the client.
type EthereumMultinodeClient ¶
EthereumMultinodeClient wraps the client and the BlockChain network to interact with an EVM based Blockchain with multiple nodes
func (*EthereumMultinodeClient) AddHeaderEventSubscription ¶
func (e *EthereumMultinodeClient) AddHeaderEventSubscription(key string, subscriber HeaderEventSubscription)
AddHeaderEventSubscription adds a new header subscriber within the client to receive new headers
func (*EthereumMultinodeClient) BalanceAt ¶ added in v1.2.3
func (e *EthereumMultinodeClient) BalanceAt(ctx context.Context, address common.Address) (*big.Int, error)
BalanceAt returns the ETH balance of the specified address
func (*EthereumMultinodeClient) Close ¶
func (e *EthereumMultinodeClient) Close() error
Close tears down the all the clients
func (*EthereumMultinodeClient) DeleteHeaderEventSubscription ¶
func (e *EthereumMultinodeClient) DeleteHeaderEventSubscription(key string)
DeleteHeaderEventSubscription removes a header subscriber from the map
func (*EthereumMultinodeClient) DeployContract ¶
func (e *EthereumMultinodeClient) DeployContract( contractName string, deployer ContractDeployer, ) (*common.Address, *types.Transaction, interface{}, error)
DeployContract deploys a specified contract
func (*EthereumMultinodeClient) EstimateCostForChainlinkOperations ¶
func (e *EthereumMultinodeClient) EstimateCostForChainlinkOperations(amountOfOperations int) (*big.Float, error)
EstimateCostForChainlinkOperations calculates TXs cost as a dirty estimation based on transactionLimit for that network
func (*EthereumMultinodeClient) EstimateTransactionGasCost ¶
func (e *EthereumMultinodeClient) EstimateTransactionGasCost() (*big.Int, error)
func (*EthereumMultinodeClient) Fund ¶
func (e *EthereumMultinodeClient) Fund(toAddress string, nativeAmount *big.Float) error
Fund funds a specified address with ETH from the given wallet
func (*EthereumMultinodeClient) GasStats ¶
func (e *EthereumMultinodeClient) GasStats() *GasStats
GasStats gets gas stats instance
func (*EthereumMultinodeClient) Get ¶
func (e *EthereumMultinodeClient) Get() interface{}
Get gets default client as an interface{}
func (*EthereumMultinodeClient) GetChainID ¶
func (e *EthereumMultinodeClient) GetChainID() *big.Int
GetChainID retrieves the ChainID of the network that the client interacts with
func (*EthereumMultinodeClient) GetClients ¶
func (e *EthereumMultinodeClient) GetClients() []EVMClient
GetClients gets clients for all nodes connected
func (*EthereumMultinodeClient) GetDefaultWallet ¶
func (e *EthereumMultinodeClient) GetDefaultWallet() *EthereumWallet
GetDefaultWallet returns the default wallet for the network
func (*EthereumMultinodeClient) GetNetworkConfig ¶
func (e *EthereumMultinodeClient) GetNetworkConfig() *EVMNetwork
GetNetworkConfig return the network config
func (*EthereumMultinodeClient) GetNetworkName ¶
func (e *EthereumMultinodeClient) GetNetworkName() string
GetNetworkName gets the ID of the chain that the clients are connected to
func (*EthereumMultinodeClient) GetTxReceipt ¶ added in v1.2.4
GetTxReceipt returns the receipt of the transaction if available, error otherwise
func (*EthereumMultinodeClient) GetWallets ¶
func (e *EthereumMultinodeClient) GetWallets() []*EthereumWallet
GetWallets returns the default wallet for the network
func (*EthereumMultinodeClient) HeaderHashByNumber ¶
func (e *EthereumMultinodeClient) HeaderHashByNumber(ctx context.Context, bn *big.Int) (string, error)
HeaderHashByNumber gets header hash by block number
func (*EthereumMultinodeClient) HeaderTimestampByNumber ¶
func (e *EthereumMultinodeClient) HeaderTimestampByNumber(ctx context.Context, bn *big.Int) (uint64, error)
HeaderTimestampByNumber gets header timestamp by number
func (*EthereumMultinodeClient) IsEventConfirmed ¶ added in v1.5.6
func (e *EthereumMultinodeClient) IsEventConfirmed(event *types.Log) (confirmed, removed bool, err error)
IsEventConfirmed returns if the default client can confirm the event has happened
func (*EthereumMultinodeClient) IsTxConfirmed ¶
func (e *EthereumMultinodeClient) IsTxConfirmed(txHash common.Hash) (bool, error)
IsTxConfirmed returns the default client's transaction confirmations
func (*EthereumMultinodeClient) LatestBlockNumber ¶
func (e *EthereumMultinodeClient) LatestBlockNumber(ctx context.Context) (uint64, error)
LatestBlockNumber gets the latest block number from the default client
func (*EthereumMultinodeClient) LoadWallets ¶
func (e *EthereumMultinodeClient) LoadWallets(cfg interface{}) error
LoadWallets loads wallets using private keys provided in the config
func (*EthereumMultinodeClient) NetworkSimulated ¶ added in v1.4.0
func (e *EthereumMultinodeClient) NetworkSimulated() bool
GetNetworkType retrieves the type of network this is running on
func (*EthereumMultinodeClient) ParallelTransactions ¶
func (e *EthereumMultinodeClient) ParallelTransactions(enabled bool)
ParallelTransactions when enabled, sends the transaction without waiting for transaction confirmations. The hashes are then stored within the client and confirmations can be waited on by calling WaitForEvents. When disabled, the minimum confirmations are waited on when the transaction is sent, so parallelisation is disabled.
func (*EthereumMultinodeClient) ProcessEvent ¶ added in v1.5.6
func (e *EthereumMultinodeClient) ProcessEvent(name string, event *types.Log, confirmedChan chan bool, errorChan chan error) error
ProcessEvent returns the result of the default client's processed event
func (*EthereumMultinodeClient) ProcessTransaction ¶
func (e *EthereumMultinodeClient) ProcessTransaction(tx *types.Transaction) error
ProcessTransaction returns the result of the default client's processed transaction
func (*EthereumMultinodeClient) SetDefaultWallet ¶
func (e *EthereumMultinodeClient) SetDefaultWallet(num int) error
SetDefaultWallet sets default wallet
func (*EthereumMultinodeClient) SetID ¶
func (e *EthereumMultinodeClient) SetID(id int)
SetID sets client ID in a multi-node environment
func (*EthereumMultinodeClient) SetWallets ¶
func (e *EthereumMultinodeClient) SetWallets(wallets []*EthereumWallet)
SetWallets sets the default client's wallets
func (*EthereumMultinodeClient) SubscribeFilterLogs ¶ added in v1.4.2
func (e *EthereumMultinodeClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, logs chan<- types.Log) (ethereum.Subscription, error)
SubscribeFilterLogs subscribes to the results of a streaming filter query.
func (*EthereumMultinodeClient) SwitchNode ¶
func (e *EthereumMultinodeClient) SwitchNode(clientID int) error
SwitchNode sets default client to perform calls to the network
func (*EthereumMultinodeClient) TransactionOpts ¶
func (e *EthereumMultinodeClient) TransactionOpts(from *EthereumWallet) (*bind.TransactOpts, error)
TransactionOpts returns the base Tx options for 'transactions' that interact with a smart contract. Since most contract interactions in this framework are designed to happen through abigen calls, it's intentionally quite bare.
func (*EthereumMultinodeClient) WaitForEvents ¶
func (e *EthereumMultinodeClient) WaitForEvents() error
WaitForEvents is a blocking function that waits for all event subscriptions for all clients
type EthereumWallet ¶
type EthereumWallet struct {
// contains filtered or unexported fields
}
EthereumWallet is the implementation to allow testing with ETH based wallets
func NewEthereumWallet ¶
func NewEthereumWallet(pk string) (*EthereumWallet, error)
NewEthereumWallet returns the instantiated ETH wallet based on a given private key
func (*EthereumWallet) Address ¶
func (e *EthereumWallet) Address() string
Address returns the ETH address for a given wallet
func (*EthereumWallet) PrivateKey ¶
func (e *EthereumWallet) PrivateKey() string
PrivateKey returns the private key for a given Ethereum wallet
func (*EthereumWallet) RawPrivateKey ¶
func (e *EthereumWallet) RawPrivateKey() interface{}
RawPrivateKey returns raw private key if it has some encoding or in bytes
type EventConfirmer ¶ added in v1.5.6
type EventConfirmer struct {
// contains filtered or unexported fields
}
EventConfirmer confirms that an event is confirmed by a certain amount of headers
func NewEventConfirmer ¶ added in v1.5.6
func NewEventConfirmer( eventName string, client EVMClient, event *types.Log, minConfirmations int, confirmedChan chan bool, errorChan chan error, ) *EventConfirmer
NewEventConfirmer returns a new instance of the event confirmer that waits for on-chain minimum confirmations
func (*EventConfirmer) Complete ¶ added in v1.5.6
func (e *EventConfirmer) Complete() bool
Complete returns if the event has officially been confirmed (true or false)
func (*EventConfirmer) ReceiveHeader ¶ added in v1.5.12
func (e *EventConfirmer) ReceiveHeader(header NodeHeader) error
ReceiveHeader will attempt to confirm an event for the chain's configured minimum confirmed headers. Errors encountered are sent along the eventErrorChan, and the result of confirming the event is sent to eventConfirmedChan.
func (*EventConfirmer) Wait ¶ added in v1.5.6
func (e *EventConfirmer) Wait() error
Wait until the event fully presents as complete
type GasStats ¶
type GasStats struct { NodeID int TotalGasUsed int64 SeenHashes map[string]bool ClientTXs []TXGasData }
GasStats helper struct to determine gas metrics across all txs of a test
func NewGasStats ¶
NewGasStats creates new gas stats collector
func (*GasStats) AddClientTXData ¶
AddClientTXData adds client TX data
func (*GasStats) PrintStats ¶
func (g *GasStats) PrintStats()
PrintStats prints gas stats and total TXs cost
type HeaderEventSubscription ¶
type HeaderEventSubscription interface { ReceiveHeader(header NodeHeader) error Wait() error Complete() bool }
HeaderEventSubscription is an interface for allowing callbacks when the client receives a new header
type InstantConfirmer ¶ added in v1.5.12
type InstantConfirmer struct {
// contains filtered or unexported fields
}
InstantConfirmer is a near-instant confirmation method, primarily for optimistic L2s that have near-instant finalization
func NewInstantConfirmer ¶ added in v1.5.12
func (*InstantConfirmer) Complete ¶ added in v1.5.12
func (l *InstantConfirmer) Complete() bool
Complete is a no-op
func (*InstantConfirmer) ReceiveHeader ¶ added in v1.5.12
func (l *InstantConfirmer) ReceiveHeader(x NodeHeader) error
ReceiveHeader does a quick check on if the tx is confirmed already
func (*InstantConfirmer) Wait ¶ added in v1.5.12
func (l *InstantConfirmer) Wait() error
Wait checks every header if the tx has been included on chain or not
type KlaytnClient ¶
type KlaytnClient struct {
*EthereumClient
}
KlaytnClient represents a single node, EVM compatible client for the Klaytn network
func (*KlaytnClient) DeployContract ¶
func (k *KlaytnClient) DeployContract( contractName string, deployer ContractDeployer, ) (*common.Address, *types.Transaction, interface{}, error)
DeployContract acts as a general contract deployment tool to an ethereum chain
func (*KlaytnClient) Fund ¶
func (k *KlaytnClient) Fund( toAddress string, amount *big.Float, ) error
Fund overrides ethereum's fund to account for Klaytn's gas specifications https://docs.klaytn.com/klaytn/design/transaction-fees#unit-price
type KlaytnMultinodeClient ¶
type KlaytnMultinodeClient struct {
*EthereumMultinodeClient
}
KlaytnMultinodeClient represents a multi-node, EVM compatible client for the Klaytn network
type MetisClient ¶
type MetisClient struct {
*EthereumClient
}
MetisClient represents a single node, EVM compatible client for the Metis network
func (*MetisClient) DeployContract ¶
func (m *MetisClient) DeployContract( contractName string, deployer ContractDeployer, ) (*common.Address, *types.Transaction, interface{}, error)
DeployContract acts as a general contract deployment tool to an EVM chain
type MetisMultinodeClient ¶
type MetisMultinodeClient struct {
*EthereumMultinodeClient
}
MetisMultinodeClient represents a multi-node, EVM compatible client for the Metis network
type NodeHeader ¶ added in v1.5.12
NodeHeader header with the ID of the node that received it
type OptimismClient ¶ added in v1.6.4
type OptimismClient struct {
*EthereumClient
}
OptimismClient represents a single node, EVM compatible client for the Optimism network
func (*OptimismClient) DeployContract ¶ added in v1.6.5
func (o *OptimismClient) DeployContract( contractName string, deployer ContractDeployer, ) (*common.Address, *types.Transaction, interface{}, error)
DeployContract deploys smart contracts specifically on Optimism
type OptimismMultinodeClient ¶ added in v1.6.4
type OptimismMultinodeClient struct {
*EthereumMultinodeClient
}
OptimismMultinodeClient represents a multi-node, EVM compatible client for the Optimism network
type PolygonEdgeClient ¶ added in v1.6.3
type PolygonEdgeClient struct {
*EthereumClient
}
PolygonEdgeClient represents a single node, EVM compatible client for the Polygon edge network
func (*PolygonEdgeClient) DeployContract ¶ added in v1.6.3
func (k *PolygonEdgeClient) DeployContract( contractName string, deployer ContractDeployer, ) (*common.Address, *types.Transaction, interface{}, error)
DeployContract acts as a general contract deployment tool to an ethereum chain
type PolygonEdgeMultinodeClient ¶ added in v1.6.3
type PolygonEdgeMultinodeClient struct {
*EthereumMultinodeClient
}
PolygonEdgeMultinodeClient represents a multi-node, EVM compatible client for the Klaytn network
type TXGasData ¶
type TXGasData struct { TXHash string Value uint64 GasLimit uint64 GasUsed uint64 GasPrice uint64 CumulativeGasUsed uint64 }
TXGasData transaction gas data
type TransactionConfirmer ¶
type TransactionConfirmer struct {
// contains filtered or unexported fields
}
TransactionConfirmer is an implementation of HeaderEventSubscription that checks whether tx are confirmed
func NewTransactionConfirmer ¶
func NewTransactionConfirmer(client EVMClient, tx *types.Transaction, minConfirmations int) *TransactionConfirmer
NewTransactionConfirmer returns a new instance of the transaction confirmer that waits for on-chain minimum confirmations
func (*TransactionConfirmer) Complete ¶ added in v1.5.6
func (t *TransactionConfirmer) Complete() bool
Complete returns if the confirmer has completed or not
func (*TransactionConfirmer) ReceiveHeader ¶ added in v1.5.12
func (t *TransactionConfirmer) ReceiveHeader(header NodeHeader) error
ReceiveHeader the implementation of the HeaderEventSubscription that receives each header and checks tx confirmation
func (*TransactionConfirmer) Wait ¶
func (t *TransactionConfirmer) Wait() error
Wait is a blocking function that waits until the transaction is complete