seth

package
v1.28.16 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: MIT Imports: 8 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var INSUFFICIENT_EPHEMERAL_KEYS = `` /* 448-byte string literal not displayed */
View Source
var INSUFFICIENT_STATIC_KEYS = `` /* 752-byte string literal not displayed */
View Source
var OneEphemeralKeysLiveTestnetAutoFixFn = func(sethCfg *pkg_seth.Config) error {
	concurrency := sethCfg.GetMaxConcurrency()

	if sethCfg.IsSimulatedNetwork() {
		if concurrency < 1 {
			return fmt.Errorf(INSUFFICIENT_EPHEMERAL_KEYS, 0)
		}

		return nil
	}

	if sethCfg.EphemeralAddrs != nil && int(*sethCfg.EphemeralAddrs) > 0 {
		var zero int64 = 0
		sethCfg.EphemeralAddrs = &zero
	}

	if concurrency < 1 {
		return fmt.Errorf(INSUFFICIENT_STATIC_KEYS, len(sethCfg.Network.PrivateKeys))
	}

	return nil
}

OneEphemeralKeysLiveTestnetAutoFixFn checks whether there's at least one ephemeral key on a simulated network or at least one static key on a live network, and that there are no epehemeral keys on a live network (if ephemeral keys count is different from zero, it will disable them). Root key is excluded from the check.

View Source
var OneEphemeralKeysLiveTestnetCheckFn = func(sethCfg *pkg_seth.Config) error {
	concurrency := sethCfg.GetMaxConcurrency()

	if sethCfg.IsSimulatedNetwork() {
		if concurrency < 1 {
			return fmt.Errorf(INSUFFICIENT_EPHEMERAL_KEYS, 0)
		}

		return nil
	}

	if sethCfg.EphemeralAddrs != nil && int(*sethCfg.EphemeralAddrs) > 0 {
		ephMsg := `
			Error: Ephemeral Addresses Detected on Live Network

			Ephemeral addresses are currently set for use on a live network, which is not permitted. The number of ephemeral addresses set is %d. Please make the following update to your TOML configuration file to correct this:
			'[Seth] ephemeral_addresses_number = 0'

			Additionally, ensure the following requirements are met to run this test on a live network:
			1. Use more than one private key in your network configuration.
			`

		return errors.New(ephMsg)
	}

	if concurrency < 1 {
		return fmt.Errorf(INSUFFICIENT_STATIC_KEYS, len(sethCfg.Network.PrivateKeys))
	}

	return nil
}

OneEphemeralKeysLiveTestnetCheckFn checks whether there's at least one ephemeral key on a simulated network or at least one static key on a live network, and that there are no epehemeral keys on a live network. Root key is excluded from the check.

Functions

func GetChainClient

func GetChainClient(c config.SethConfig, network blockchain.EVMNetwork) (*pkg_seth.Client, error)

GetChainClient returns a seth client for the given network after validating the config

func GetChainClientWithConfigFunction

func GetChainClientWithConfigFunction(c config.SethConfig, network blockchain.EVMNetwork, configFn ConfigFunction) (*pkg_seth.Client, error)

GetChainClientWithConfigFunction returns a seth client for the given network after validating the config and applying the config function

func MergeSethAndEvmNetworkConfigs

func MergeSethAndEvmNetworkConfigs(evmNetwork blockchain.EVMNetwork, sethConfig pkg_seth.Config) (pkg_seth.Config, error)

MergeSethAndEvmNetworkConfigs merges EVMNetwork to Seth config. If Seth config already has Network settings, it will return unchanged Seth config that was passed to it. If the network is simulated, it will use Geth-specific settings. Otherwise it will use the chain ID to find the correct network settings. If no match is found it will return error.

func MustReplaceSimulatedNetworkUrlWithK8

func MustReplaceSimulatedNetworkUrlWithK8(l zerolog.Logger, network blockchain.EVMNetwork, testEnvironment environment.Environment) blockchain.EVMNetwork

MustReplaceSimulatedNetworkUrlWithK8 replaces the simulated network URL with the K8 URL and returns the network. If the network is not simulated, it will return the network unchanged.

func ValidateSethNetworkConfig

func ValidateSethNetworkConfig(cfg *pkg_seth.Network) error

ValidateSethNetworkConfig validates the Seth network config

Types

type ConfigFunction

type ConfigFunction = func(*pkg_seth.Config) error

Jump to

Keyboard shortcuts

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