test_env

package
v1.51.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: MIT Imports: 54 Imported by: 15

Documentation

Index

Constants

View Source
const (
	RootFundingAddr   = `0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266`
	RootFundingWallet = `` /* 491-byte string literal not displayed */

	DEFAULT_EVM_NODE_HTTP_PORT = "8544"
	DEFAULT_EVM_NODE_WS_PORT   = "8545"
)
View Source
const (
	PRYSM_QUERY_RPC_PORT = "3500"
	PRYSM_NODE_RPC_PORT  = "4000"
)
View Source
const AUTOMATIC_LATEST_TAG = "latest_available"
View Source
const AUTOMATIC_STABLE_LATEST_TAG = "latest_stable"
View Source
const (
	BaseCMD = `docker run -i --rm -v /var/run/docker.sock:/var/run/docker.sock --network %s gaiaadm/pumba --log-level=info`
)
View Source
const (
	CONFIG_ENV_VAR_NAME = "PRIVATE_ETHEREUM_NETWORK_CONFIG_PATH"
)

Variables

View Source
var (
	ETH2_EXECUTION_PORT                           = "8551"
	WALLET_PASSWORD                               = "password"
	GENERATED_VALIDATOR_KEYS_DIR_INSIDE_CONTAINER = "/keys"
	NODE_0_DIR_INSIDE_CONTAINER                   = fmt.Sprintf("%s/node-0", GENERATED_VALIDATOR_KEYS_DIR_INSIDE_CONTAINER)
	VALIDATOR_BIP39_MNEMONIC                      = "" /* 152-byte string literal not displayed */
)
View Source
var (
	ErrMissingConsensusLayer = errors.New("consensus layer is required for PoS")
	ErrTestConfigNotSaved    = errors.New("could not save test env config")
)
View Source
var FundingAddresses = map[string]string{
	"f39fd6e51aad88f6f4ce6ab8827279cfffb92266": `{"address":"f39fd6e51aad88f6f4ce6ab8827279cfffb92266","crypto":{"cipher":"aes-128-ctr","ciphertext":"c36afd6e60b82d6844530bd6ab44dbc3b85a53e826c3a7f6fc6a75ce38c1e4c6","cipherparams":{"iv":"f69d2bb8cd0cb6274535656553b61806"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"80d5f5e38ba175b6b89acfc8ea62a6f163970504af301292377ff7baafedab53"},"mac":"f2ecec2c4d05aacc10eba5235354c2fcc3776824f81ec6de98022f704efbf065"},"id":"e5c124e9-e280-4b10-a27b-d7f3e516b408","version":3}`,
	"70997970c51812dc3a010c7d01b50e0d17dc79c8": `{"address":"70997970c51812dc3a010c7d01b50e0d17dc79c8","crypto":{"cipher":"aes-128-ctr","ciphertext":"f8183fa00bc112645d3e23e29a233e214f7c708bf49d72750c08af88ad76c980","cipherparams":{"iv":"796d08e3e1f71bde89ed826abda96cda"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"03c864a22a1f7b06b1da12d8b93e024ac144f898285907c58b2abc135fc8a35c"},"mac":"5fe91b1a1821c0d9f85dfd582354ead9612e9a7e9adc38b06a2beff558c119ac"},"id":"d2cab765-5e30-42ae-bb91-f090d9574fae","version":3}`,
	"3c44cdddb6a900fa2b585dd299e03d12fa4293bc": `{"address":"3c44cdddb6a900fa2b585dd299e03d12fa4293bc","crypto":{"cipher":"aes-128-ctr","ciphertext":"2cd6ab87086c47f343f2c4d957eace7986f3b3c87fc35a2aafbefb57a06d9f1c","cipherparams":{"iv":"4e16b6cd580866c1aa642fb4d7312c9b"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"0cabde93877f6e9a59070f9992f7a01848618263124835c90d4d07a0041fc57c"},"mac":"94b7776ea95b0ecd8406c7755acf17b389b7ebe489a8942e32082dfdc1f04f57"},"id":"ade1484b-a3bb-426f-9223-a1f5e3bde2e8","version":3}`,
	"90f79bf6eb2c4f870365e785982e1f101e93b906": `{"address":"90f79bf6eb2c4f870365e785982e1f101e93b906","crypto":{"cipher":"aes-128-ctr","ciphertext":"15144214d323871e00f7b205368128061c91b77a27b7deec935f8f5b734f0d42","cipherparams":{"iv":"bb22ba8051ef9f60abded7a9f4f2c6ae"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"07331ef3035567c00830b4e50d5dd68bc877974b4ce38cd42fef755be01556c9"},"mac":"2294eacadaf2761851814451d8c7dcca20a606a0344335d98f09403aba4e82ca"},"id":"96af8cc7-97e1-4bba-8968-632b034986c2","version":3}`,
	"15d34aaf54267db7d7c367839aaf71a00a2c6a65": `{"address":"15d34aaf54267db7d7c367839aaf71a00a2c6a65","crypto":{"cipher":"aes-128-ctr","ciphertext":"057878284a6c74d3ad99910adddd6b477b383837dbf2280efea585f0f0fdb012","cipherparams":{"iv":"e6eab29d60b526f305f8d47badf48687"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"dfdca8066d2486da5cb9a909d03744e2a8c6537930271e85e7cd8a5d952c0f22"},"mac":"f8352be41c9a06d69111ca4d8fcff0eef079b68b1173cad99803538991716c5d"},"id":"a35bb452-0d57-42d5-8d25-5a00a40a4db8","version":3}`,
	"9965507d1a55bcc2695c58ba16fb37d819b0a4dc": `{"address":"9965507d1a55bcc2695c58ba16fb37d819b0a4dc","crypto":{"cipher":"aes-128-ctr","ciphertext":"5a73201500307c6aa98edd44d962b344a893768331454a61595ec848e738e9d2","cipherparams":{"iv":"5282de2b3e2b305019a2fed5c62f3383"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"6ad001831d097f175fff7d6cf61301e9620b32afd9a7a6437e6030af14576a96"},"mac":"0a55eddbd13c713aa8b8c4106b2fb62bc1d1e18e7177207a444f83a4d8426ed5"},"id":"27aed2b2-cb94-4d37-8819-b15219187bb5","version":3}`,
	"976ea74026e726554db657fa54763abd0c3a0aa9": `{"address":"976ea74026e726554db657fa54763abd0c3a0aa9","crypto":{"cipher":"aes-128-ctr","ciphertext":"a6edf11e81b38e60a549696236cb9efc026e87adc45a9521ea7b2c45a2a9fbb9","cipherparams":{"iv":"82f4c79cd4b28a8585a9c78d758f832b"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"87400e16ecc320dadff85eccbf4dbaaea2dd91e50047e4aa391799bb319c1fd8"},"mac":"80c83dad05998db6c673a97096fcfad54636458f4a3c82483686b253f8cc9b69"},"id":"fc7d7694-6206-48fc-bb25-36b523f90df6","version":3}`,
	"14dc79964da2c08b23698b3d3cc7ca32193d9955": `{"address":"14dc79964da2c08b23698b3d3cc7ca32193d9955","crypto":{"cipher":"aes-128-ctr","ciphertext":"410f258bc8b12a0250cba22cbc5e413534fcf90bf322ced6943189ad9e43b4b9","cipherparams":{"iv":"1dd6077a8bee9b3bf2ca90e6abc8a237"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"5d3358bf99bbcb82354f40e5501abf4336bc141ee05d8feed4fbe7eb8c08c917"},"mac":"9cd959fa1e8129a8deb86e0264ec81d6cde79b5a19ae259b7d00543c9037908a"},"id":"689d7ad2-fe46-4c09-9c2a-a50e607989b8","version":3}`,
	"23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f": `{"address":"23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f","crypto":{"cipher":"aes-128-ctr","ciphertext":"13dccac740314edea20d44e6f3592575bbcb739ec5892d635326cff3c386eb86","cipherparams":{"iv":"bf42d811cd41fa97ddcae3425f8c3211"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"d2fa67cbb5e86d5bf9a90e27b8747bac493614b45778d43e9da1c14e06b2401d"},"mac":"7d2797cf344704d8f36265238d3938e06952c78ab7dfcbac53dc7f472c93d933"},"id":"4c8e899e-80f0-4417-9b1e-c5e29049f1e7","version":3}`,
	"a0ee7a142d267c1f36714e4a8f75612f20a79720": `{"address":"a0ee7a142d267c1f36714e4a8f75612f20a79720","crypto":{"cipher":"aes-128-ctr","ciphertext":"56bc8766f47aeafae74eea333e1e890a3776d7fae6c48cbdbffb270655ce050d","cipherparams":{"iv":"a66129e6a110b3ddf93b4355aa147c58"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"15c4e8bcc80920139eb236d91194825f1fce27dd2af281e0f2752d8a5dbc48bd"},"mac":"db01e720866ce8bb7897dfc7773e064003ad53429a79732ee769cf6d02273570"},"id":"87b2d76f-1b70-4e4f-8b2a-5d1915c1177c","version":3}`,
	"bcd4042de499d14e55001ccbb24a551f3b954096": `{"address":"bcd4042de499d14e55001ccbb24a551f3b954096","crypto":{"cipher":"aes-128-ctr","ciphertext":"e455eda6e38d246c03b930f845adfc8721ca75e9f47135cd4c18dbc3e5c5440a","cipherparams":{"iv":"0b1a0a24acc1ad25b0f170f751c2cb27"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"69f324ed0787794878bf5f84d4dbbc70dec1274cad666399edc48640605f64c8"},"mac":"f07da09c460a69f943f5639545d2b3f72c1e9789f0421ad41d3078ea3db12c96"},"id":"7ec7bb3c-c486-4785-a4fc-f8f4b2fc7764","version":3}`,
	"71be63f3384f5fb98995898a86b02fb2426c5788": `{"address":"71be63f3384f5fb98995898a86b02fb2426c5788","crypto":{"cipher":"aes-128-ctr","ciphertext":"4194377a05fd3d13e0a3155dad974a003fe5f7a3b5acb35d7d97c50daa8990d4","cipherparams":{"iv":"607670778baf62b1e86394cf1980487a"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"d63b890ad7f4fcc857681faabe9319dffc53893966ef0810bf64c4f319b0ffc5"},"mac":"bfaf924959e65c8030ece259d52ed52d5d21bd74f1a67ae545d4bb289a479e16"},"id":"0c6af842-384f-49b6-b5b7-199a1e05486b","version":3}`,
}
View Source
var MsgMismatchedExecutionClient = "" /* 147-byte string literal not displayed */
View Source
var UNSUPPORTED_VERSIONS = []UnsupportedVersion{
	{DockerImage: fmt.Sprintf("%s:1.20.0", ethereum.NethermindBaseImageName),
		Reason: "1.20.0 was replaced with 1.20.1, for more info check https://github.com/NethermindEth/nethermind/releases/tag/1.20.0",
	},
	{DockerImage: fmt.Sprintf("%s:v1.9.0", ethereum.GethBaseImageName),
		Reason: "v1.9.0 randomly drops websocket connections, for more info check https://github.com/ethereum/go-ethereum/issues/19001",
	},
}

Functions

func FetchLatestEthereumClientDockerImageVersionIfNeed

func FetchLatestEthereumClientDockerImageVersionIfNeed(dockerImageWithVersion string) (string, error)

FetchLatestEthereumClientDockerImageVersionIfNeed fetches the latest release version from Github if the version is set to AUTOMATIC_LATEST_TAG or AUTOMATIC_STABLE_LATEST_TAG and returns the full docker image with the latest version. Works only for supported Ethereum clients: Geth, Erigon, Besu and Nethermind.

func FormatHttpUrl

func FormatHttpUrl(host string, port string) string

FormatHttpUrl constructs a standard HTTP URL using the provided host and port. This function is useful for generating URLs for services running in a containerized environment.

func FormatWsUrl

func FormatWsUrl(host string, port string) string

FormatWsUrl constructs a WebSocket URL using the provided host and port. This function is useful for establishing WebSocket connections to Ethereum nodes.

func GetEndpoint

func GetEndpoint(ctx context.Context, container tc.Container, endpointType string) (string, error)

GetEndpoint returns the endpoint of a container, if localhost then force ipv4 localhost to avoid ipv6 docker bugs https://github.com/moby/moby/issues/42442 https://github.com/moby/moby/issues/42375

func GetEndpointFromPort added in v1.50.3

func GetEndpointFromPort(ctx context.Context, container tc.Container, endpointType string, portStr string) (string, error)

GetEndpointFromPort returns the endpoint of a container associated with a port, if localhost then force ipv4 localhost to avoid ipv6 docker bugs https://github.com/moby/moby/issues/42442 https://github.com/moby/moby/issues/42375

func GetHost

func GetHost(ctx context.Context, container tc.Container) (string, error)

GetHost returns the host of a container, if localhost then force ipv4 localhost to avoid ipv6 docker bugs https://github.com/moby/moby/issues/42442 https://github.com/moby/moby/issues/42375

func IsDockerImageVersionSupported

func IsDockerImageVersionSupported(imageWithVersion string) (bool, string, error)

IsDockerImageVersionSupported checks if the given docker image version is supported and if not returns the reason why

func NatPort

func NatPort(port string) nat.Port

NatPort converts a string representation of a port into a nat.Port type. This is useful for ensuring that the port is formatted correctly for networking operations.

func NatPortFormat

func NatPortFormat(port string) string

NatPortFormat formats a given port string to include the TCP protocol suffix. This is useful for standardizing port representations in container configurations.

func UniqueStringSlice

func UniqueStringSlice(slice []string) []string

UniqueStringSlice returns a deduplicated slice of strings

Types

type AfterGenesisHelper

type AfterGenesisHelper struct {
	EnvComponent
	// contains filtered or unexported fields
}

func NewInitHelper

func NewInitHelper(chainConfig config.EthereumChainConfig, generatedDataHostDir, generatedDataContainerDir string, opts ...EnvComponentOption) *AfterGenesisHelper

NewInitHelper initializes a new AfterGenesisHelper instance with the provided chain configuration and directory paths. It sets up necessary environment components and options, facilitating the management of post-genesis operations in a blockchain network.

func (*AfterGenesisHelper) StartContainer

func (g *AfterGenesisHelper) StartContainer() error

StartContainer initializes and starts the After Genesis Helper container. It handles container requests and logs the startup process, ensuring the container is ready for use.

func (*AfterGenesisHelper) WithTestInstance

func (g *AfterGenesisHelper) WithTestInstance(t *testing.T) *AfterGenesisHelper

WithTestInstance sets up the AfterGenesisHelper for testing by assigning a logger and test context. This allows for better logging and error tracking during test execution.

type Besu

type Besu struct {
	EnvComponent
	ExternalHttpUrl      string
	InternalHttpUrl      string
	ExternalWsUrl        string
	InternalWsUrl        string
	InternalExecutionURL string
	ExternalExecutionURL string
	// contains filtered or unexported fields
}

func NewBesuEth1

func NewBesuEth1(networks []string, chainConfig *config.EthereumChainConfig, opts ...EnvComponentOption) (*Besu, error)

NewBesuEth1 starts a new Besu Eth1 node running in Docker

func NewBesuEth2

func NewBesuEth2(networks []string, chainConfig *config.EthereumChainConfig, generatedDataHostDir, generatedDataContainerDir string, consensusLayer config.ConsensusLayer, opts ...EnvComponentOption) (*Besu, error)

NewBesuEth2 starts a new Besu Eth2 node running in Docker

func (*Besu) GetConsensusMechanism added in v1.50.20

func (g *Besu) GetConsensusMechanism() ConsensusMechanism

GetConsensusMechanism returns the consensus mechanism used by the Besu instance. It identifies whether the Ethereum version is Eth1 or not, returning either Proof of Authority (PoA) or Proof of Stake (PoS) accordingly. This is useful for understanding the network's validation method.

func (*Besu) GetContainer

func (g *Besu) GetContainer() *tc.Container

GetContainer returns a pointer to the container associated with the Besu instance. This function is useful for accessing the container's properties and methods in other operations.

func (*Besu) GetContainerName

func (g *Besu) GetContainerName() string

GetContainerName returns the name of the container associated with the Besu instance. This function is useful for identifying and managing the container in a Docker environment.

func (*Besu) GetEthereumVersion

func (g *Besu) GetEthereumVersion() config_types.EthereumVersion

GetEthereumVersion returns the current Ethereum version of the Besu instance. This information is crucial for determining the appropriate container configuration and consensus mechanism.

func (*Besu) GetExternalExecutionURL

func (g *Besu) GetExternalExecutionURL() string

GetExternalExecutionURL returns the external execution URL for the Besu instance. It panics if the Ethereum version is Eth1, as Eth1 nodes do not support execution URLs.

func (*Besu) GetExternalHttpUrl

func (g *Besu) GetExternalHttpUrl() string

GetExternalHttpUrl returns the external HTTP URL of the Besu client. This URL is used to interact with the Besu node from external applications or services.

func (*Besu) GetExternalWsUrl

func (g *Besu) GetExternalWsUrl() string

GetExternalWsUrl returns the external WebSocket URL for the Besu client. This URL is essential for connecting to the Besu node from external services or clients.

func (*Besu) GetInternalExecutionURL

func (g *Besu) GetInternalExecutionURL() string

GetInternalExecutionURL returns the internal execution URL for the Besu client. It is used to retrieve the endpoint for executing transactions in Ethereum 2.0 networks, ensuring compatibility with the Ethereum version in use.

func (*Besu) GetInternalHttpUrl

func (g *Besu) GetInternalHttpUrl() string

GetInternalHttpUrl returns the internal HTTP URL of the Besu client. This URL is essential for establishing communication with the Besu node in a private network setup.

func (*Besu) GetInternalWsUrl

func (g *Besu) GetInternalWsUrl() string

GetInternalWsUrl returns the internal WebSocket URL for the Besu client. This URL is essential for establishing WebSocket connections to the Besu node for real-time data and event subscriptions.

func (*Besu) StartContainer

func (g *Besu) StartContainer() (blockchain.EVMNetwork, error)

StartContainer initializes and starts a Besu container for Ethereum execution. It configures network settings based on the Ethereum version and returns the network configuration along with any errors encountered during the process.

func (*Besu) WaitUntilChainIsReady

func (g *Besu) WaitUntilChainIsReady(ctx context.Context, waitTime time.Duration) error

WaitUntilChainIsReady blocks until the Ethereum chain is ready for operations. It is useful for ensuring that the execution client has fully synchronized with the network before proceeding with further actions.

func (*Besu) WithTestInstance

func (g *Besu) WithTestInstance(t *testing.T) ExecutionClient

WithTestInstance sets up the execution client for testing by assigning a test logger and the testing context. This allows for better logging and error tracking during test execution.

type ConsensusMechanism

type ConsensusMechanism string
const (
	ConsensusMechanism_PoW ConsensusMechanism = "pow"
	ConsensusMechanism_PoS ConsensusMechanism = "pos"
	ConsensusMechanism_PoA ConsensusMechanism = "poa"
)

type EnvComponent

type EnvComponent struct {
	ContainerName      string             `json:"containerName"`
	ContainerImage     string             `json:"containerImage"`
	ContainerVersion   string             `json:"containerVersion"`
	ContainerEnvs      map[string]string  `json:"containerEnvs"`
	WasRecreated       bool               `json:"wasRecreated"`
	Networks           []string           `json:"networks"`
	Container          tc.Container       `json:"-"`
	PostStartsHooks    []tc.ContainerHook `json:"-"`
	PostStopsHooks     []tc.ContainerHook `json:"-"`
	PreTerminatesHooks []tc.ContainerHook `json:"-"`
	LogLevel           string             `json:"-"`
	StartupTimeout     time.Duration      `json:"-"`
}

func (EnvComponent) ChaosNetworkDelay

func (ec EnvComponent) ChaosNetworkDelay(
	l zerolog.Logger,
	duration time.Duration,
	delay time.Duration,
	targetInterfaceName string,
	targetIPs []string,
	targetIngressPorts []string,
	targetEgressPorts []string,
) error

ChaosNetworkDelay delays the container's network traffic for the specified duration

func (EnvComponent) ChaosNetworkLoss

func (ec EnvComponent) ChaosNetworkLoss(
	l zerolog.Logger,
	duration time.Duration,
	lossPercentage int,
	targetInterfaceName string,
	targetIPs []string,
	targetIngressPorts []string,
	targetEgressPorts []string,
) error

ChaosNetworkLoss causes the container to lose the specified percentage of network traffic for the specified duration

func (EnvComponent) ChaosPause

func (ec EnvComponent) ChaosPause(
	l zerolog.Logger,
	duration time.Duration,
) error

ChaosPause pauses the container for the specified duration

func (*EnvComponent) GetImageWithVersion

func (ec *EnvComponent) GetImageWithVersion() string

GetImageWithVersion returns the container image name combined with its version. This function is useful for generating a complete image identifier needed for container requests.

func (*EnvComponent) SetDefaultHooks

func (ec *EnvComponent) SetDefaultHooks()

SetDefaultHooks initializes the default hooks for the environment component. This function is useful for ensuring that the component has a consistent starting state before further configuration.

type EnvComponentOption

type EnvComponentOption = func(c *EnvComponent)

func WithContainerImageWithVersion

func WithContainerImageWithVersion(imageWithVersion string) EnvComponentOption

WithContainerImageWithVersion sets the container image and version for an EnvComponent. It splits the provided image string by ':' and assigns the values accordingly. This function is useful for configuring specific container images in a deployment.

func WithContainerName

func WithContainerName(name string) EnvComponentOption

WithContainerName sets the container name for an EnvComponent. It allows customization of the container's identity, enhancing clarity and organization in containerized environments.

func WithLogLevel

func WithLogLevel(logLevel string) EnvComponentOption

WithLogLevel sets the logging level for an environment component. It allows customization of log verbosity, enhancing debugging and monitoring capabilities.

func WithPostStartsHooks

func WithPostStartsHooks(hooks ...tc.ContainerHook) EnvComponentOption

WithPostStartsHooks sets the PostStarts hooks for an EnvComponent. This allows users to define custom actions that should occur after the component starts.

func WithPostStopsHooks

func WithPostStopsHooks(hooks ...tc.ContainerHook) EnvComponentOption

WithPostStopsHooks sets the PostStops hooks for an EnvComponent. This allows users to define custom actions that should occur after the component stops.

func WithPreTerminatesHooks

func WithPreTerminatesHooks(hooks ...tc.ContainerHook) EnvComponentOption

WithPreTerminatesHooks sets the pre-termination hooks for an EnvComponent. This allows users to define custom behavior that should occur before the component is terminated.

func WithStartupTimeout

func WithStartupTimeout(timeout time.Duration) EnvComponentOption

WithStartupTimeout sets a custom startup timeout for an EnvComponent. This option allows users to specify how long to wait for the component to start before timing out, enhancing control over component initialization.

type Erigon

type Erigon struct {
	EnvComponent
	ExternalHttpUrl      string
	InternalHttpUrl      string
	ExternalWsUrl        string
	InternalWsUrl        string
	InternalExecutionURL string
	ExternalExecutionURL string
	// contains filtered or unexported fields
}

func NewErigonEth1

func NewErigonEth1(networks []string, chainConfig *config.EthereumChainConfig, opts ...EnvComponentOption) (*Erigon, error)

NewErigonEth1 starts a new Erigon Eth1 node running in Docker

func NewErigonEth2

func NewErigonEth2(networks []string, chainConfig *config.EthereumChainConfig, generatedDataHostDir, generatedDataContainerDir string, consensusLayer config.ConsensusLayer, opts ...EnvComponentOption) (*Erigon, error)

NewErigonEth2 starts a new Erigon Eth2 node running in Docker

func (*Erigon) GetConsensusMechanism added in v1.50.20

func (g *Erigon) GetConsensusMechanism() ConsensusMechanism

GetConsensusMechanism returns the consensus mechanism used by the Erigon instance. It identifies whether the Ethereum version is Eth1 (Proof of Work) or a later version (Proof of Stake).

func (*Erigon) GetContainer

func (g *Erigon) GetContainer() *tc.Container

GetContainer returns a pointer to the Container associated with the Erigon instance. This function is useful for accessing the container's properties and methods in a structured manner.

func (*Erigon) GetContainerName

func (g *Erigon) GetContainerName() string

GetContainerName returns the name of the container associated with the Erigon instance. This function is useful for identifying and managing the container in a Docker environment.

func (*Erigon) GetEthereumVersion

func (g *Erigon) GetEthereumVersion() config_types.EthereumVersion

GetEthereumVersion returns the current Ethereum version of the Erigon instance. This information is essential for determining the appropriate execution URLs and consensus mechanisms.

func (*Erigon) GetExternalExecutionURL

func (g *Erigon) GetExternalExecutionURL() string

GetExternalExecutionURL returns the external execution URL for the Erigon instance. It panics if the Ethereum version is Eth1, as Eth1 nodes do not support execution URLs.

func (*Erigon) GetExternalHttpUrl

func (g *Erigon) GetExternalHttpUrl() string

GetExternalHttpUrl returns the external HTTP URL for the Erigon client. This URL is used to interact with the Erigon execution layer over HTTP.

func (*Erigon) GetExternalWsUrl

func (g *Erigon) GetExternalWsUrl() string

GetExternalWsUrl returns the external WebSocket URL for the Erigon client. This URL is essential for connecting to the Erigon node for real-time data and event subscriptions.

func (*Erigon) GetInternalExecutionURL

func (g *Erigon) GetInternalExecutionURL() string

GetInternalExecutionURL returns the internal execution URL for the Erigon client. It is used to retrieve the execution layer's endpoint, essential for connecting to the Ethereum network. If the Ethereum version is Eth1, it panics as Eth1 nodes do not support execution URLs.

func (*Erigon) GetInternalHttpUrl

func (g *Erigon) GetInternalHttpUrl() string

GetInternalHttpUrl returns the internal HTTP URL of the Erigon client. This URL is used to connect to the Erigon execution layer for internal communications.

func (*Erigon) GetInternalWsUrl

func (g *Erigon) GetInternalWsUrl() string

GetInternalWsUrl returns the internal WebSocket URL for the Erigon client. This URL is used to establish a WebSocket connection for real-time communication with the Erigon node.

func (*Erigon) StartContainer

func (g *Erigon) StartContainer() (blockchain.EVMNetwork, error)

StartContainer initializes and starts an Erigon container for Ethereum execution. It configures network settings based on the Ethereum version and returns the blockchain network configuration along with any errors encountered during the process.

func (*Erigon) WaitUntilChainIsReady

func (g *Erigon) WaitUntilChainIsReady(ctx context.Context, waitTime time.Duration) error

WaitUntilChainIsReady blocks until the Ethereum chain is ready for use, waiting for the first block to be built. It returns an error if the chain does not become ready within the specified wait time.

func (*Erigon) WithTestInstance

func (g *Erigon) WithTestInstance(t *testing.T) ExecutionClient

WithTestInstance sets up the execution client with a test logger and test context. This is useful for running tests that require a specific logging setup and context.

type EthGenesisGenerator

type EthGenesisGenerator struct {
	EnvComponent
	// contains filtered or unexported fields
}

func NewEthGenesisGenerator

func NewEthGenesisGenerator(chainConfig config.EthereumChainConfig, generatedDataHostDir string, lastFork ethereum.Fork, opts ...EnvComponentOption) (*EthGenesisGenerator, error)

NewEthGenesisGenerator initializes a new EthGenesisGenerator instance for generating Ethereum genesis data. It requires the Ethereum chain configuration, a directory for generated data, and the last fork used. This function is essential for setting up the environment to create and manage Ethereum genesis files.

func (*EthGenesisGenerator) GetGeneratedDataContainerDir

func (g *EthGenesisGenerator) GetGeneratedDataContainerDir() string

GetGeneratedDataContainerDir returns the directory path for the generated data container. This is useful for accessing the location where the genesis data is stored after generation.

func (*EthGenesisGenerator) StartContainer

func (g *EthGenesisGenerator) StartContainer() error

StartContainer initializes and starts the Ethereum genesis generation container. It ensures the container is ready for use, logging the process and any errors encountered.

func (*EthGenesisGenerator) WithTestInstance

func (g *EthGenesisGenerator) WithTestInstance(t *testing.T) *EthGenesisGenerator

WithTestInstance sets up the EthGenesisGenerator for testing by assigning a logger and test context. This allows for better logging and error tracking during test execution.

type EthereumNetwork

type EthereumNetwork struct {
	config.EthereumNetworkConfig
	// contains filtered or unexported fields
}

func NewPrivateChainEnvConfigFromFile

func NewPrivateChainEnvConfigFromFile(path string) (EthereumNetwork, error)

NewPrivateChainEnvConfigFromFile loads an EthereumNetwork configuration from a TOML file specified by the given path. It returns the populated EthereumNetwork struct and any error encountered during the file reading or parsing process.

func (*EthereumNetwork) Save

func (en *EthereumNetwork) Save() error

Save persists the configuration of the Ethereum network to a TOML file. It generates a unique filename and logs the path for future reference in end-to-end tests. This function is essential for maintaining consistent test environments.

func (*EthereumNetwork) Start

Start initializes and starts the Ethereum network based on the specified version. It returns the configured blockchain network, RPC provider, and any error encountered during the process.

type EthereumNetworkBuilder

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

func NewEthereumNetworkBuilder

func NewEthereumNetworkBuilder() EthereumNetworkBuilder

NewEthereumNetworkBuilder initializes a new EthereumNetworkBuilder with default settings. It prepares the builder for configuring an Ethereum network, allowing customization of various parameters.

func (*EthereumNetworkBuilder) Build

Build constructs an EthereumNetwork based on the provided configuration settings. It validates the configuration, auto-fills missing values, and handles both existing and new setups. This function is essential for initializing a private Ethereum chain environment.

func (*EthereumNetworkBuilder) WithConsensusLayer

func (b *EthereumNetworkBuilder) WithConsensusLayer(consensusLayer config.ConsensusLayer) *EthereumNetworkBuilder

WithConsensusLayer sets the consensus layer for the Ethereum network builder. It allows users to specify the consensus mechanism to be used, ensuring compatibility with the selected Ethereum version and execution layer.

func (*EthereumNetworkBuilder) WithConsensusType

func (b *EthereumNetworkBuilder) WithConsensusType(consensusType config.ConsensusType) *EthereumNetworkBuilder

WithConsensusType sets the consensus type for the network Deprecated: use WithEthereumVersion() instead

func (*EthereumNetworkBuilder) WithCustomDockerImages

func (b *EthereumNetworkBuilder) WithCustomDockerImages(newImages map[config.ContainerType]string) *EthereumNetworkBuilder

WithCustomDockerImages sets custom Docker images for the Ethereum network builder. This allows users to specify their own container images for different components, enabling greater flexibility and customization in the network setup.

func (*EthereumNetworkBuilder) WithDockerNetworks

func (b *EthereumNetworkBuilder) WithDockerNetworks(networks []string) *EthereumNetworkBuilder

WithDockerNetworks sets the Docker networks for the Ethereum network builder. It allows users to specify custom networks for containerized deployments, enhancing flexibility in network configuration.

func (*EthereumNetworkBuilder) WithEthereumChainConfig

func (b *EthereumNetworkBuilder) WithEthereumChainConfig(config config.EthereumChainConfig) *EthereumNetworkBuilder

WithEthereumChainConfig sets the Ethereum chain configuration for the network builder. This allows customization of parameters such as validator count and chain ID, enabling tailored network setups.

func (*EthereumNetworkBuilder) WithEthereumVersion

func (b *EthereumNetworkBuilder) WithEthereumVersion(ethereumVersion config_types.EthereumVersion) *EthereumNetworkBuilder

WithEthereumVersion sets the Ethereum version for the network builder. It allows users to specify whether to use 'eth1' or 'eth2' for their Ethereum network configuration.

func (*EthereumNetworkBuilder) WithExecutionLayer

func (b *EthereumNetworkBuilder) WithExecutionLayer(executionLayer config_types.ExecutionLayer) *EthereumNetworkBuilder

WithExecutionLayer sets the execution layer for the Ethereum network builder. It allows users to specify which execution layer to use, ensuring compatibility with the selected Ethereum version and consensus layer.

func (*EthereumNetworkBuilder) WithExistingConfig

WithExistingConfig sets an existing Ethereum network configuration for the builder. It allows users to customize the network setup using predefined settings, facilitating the creation of a network with specific parameters.

func (*EthereumNetworkBuilder) WithExistingConfigFromEnvVar

func (b *EthereumNetworkBuilder) WithExistingConfigFromEnvVar() *EthereumNetworkBuilder

WithExistingConfigFromEnvVar enables the use of an existing Ethereum configuration sourced from an environment variable. This allows for flexible deployment configurations without hardcoding values, enhancing security and adaptability.

func (*EthereumNetworkBuilder) WithNodeLogLevel

func (b *EthereumNetworkBuilder) WithNodeLogLevel(nodeLogLevel string) *EthereumNetworkBuilder

WithNodeLogLevel sets the logging level for the Ethereum node. This function allows users to customize the verbosity of logs, aiding in debugging and monitoring of the node's operations.

func (*EthereumNetworkBuilder) WithTest

WithTest sets the testing context for the Ethereum network builder. It allows for integration testing by associating a *testing.T instance, enabling error reporting and test management during network setup.

func (*EthereumNetworkBuilder) WithWaitingForFinalization

func (b *EthereumNetworkBuilder) WithWaitingForFinalization() *EthereumNetworkBuilder

WithWaitingForFinalization enables the builder to wait for transaction finalization before proceeding. This is useful for ensuring that the blockchain state is stable and confirmed before executing subsequent operations.

type ExecutionClient

type ExecutionClient interface {
	GetContainerName() string
	StartContainer() (blockchain.EVMNetwork, error)
	GetContainer() *tc.Container
	GetInternalExecutionURL() string
	GetExternalExecutionURL() string
	GetInternalHttpUrl() string
	GetInternalWsUrl() string
	GetExternalHttpUrl() string
	GetExternalWsUrl() string
	GetEthereumVersion() config_types.EthereumVersion
	GetConsensusMechanism() ConsensusMechanism
	WaitUntilChainIsReady(ctx context.Context, waitTime time.Duration) error
	WithTestInstance(t *testing.T) ExecutionClient
}

type ExitCodeStrategy

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

func NewExitCodeStrategy

func NewExitCodeStrategy() *ExitCodeStrategy

NewExitCodeStrategy initializes a new ExitCodeStrategy with default settings. It sets the expected exit code to 0, a timeout of 2 minutes, and a poll interval of 2 seconds. This function is useful for configuring container readiness checks based on exit codes.

func (*ExitCodeStrategy) WaitUntilReady

func (w *ExitCodeStrategy) WaitUntilReady(ctx context.Context, target tcwait.StrategyTarget) (err error)

WaitUntilReady implements Strategy.WaitUntilReady

func (*ExitCodeStrategy) WithExitCode

func (w *ExitCodeStrategy) WithExitCode(exitCode int) *ExitCodeStrategy

WithExitCode sets the expected exit code for the strategy and returns the updated instance. This function is useful for configuring container requests to wait for specific exit conditions.

func (*ExitCodeStrategy) WithPollInterval

func (w *ExitCodeStrategy) WithPollInterval(pollInterval time.Duration) *ExitCodeStrategy

WithPollInterval sets the interval for polling the exit code and returns the updated strategy. This function is useful for configuring how frequently to check the exit code during container execution.

func (*ExitCodeStrategy) WithTimeout

func (w *ExitCodeStrategy) WithTimeout(timeout time.Duration) *ExitCodeStrategy

WithTimeout sets the timeout duration for the ExitCodeStrategy. It allows users to specify how long to wait for a process to exit with the expected code.

type Geth

type Geth struct {
	EnvComponent
	ExternalHttpUrl      string
	InternalHttpUrl      string
	ExternalWsUrl        string
	InternalWsUrl        string
	InternalExecutionURL string
	ExternalExecutionURL string
	// contains filtered or unexported fields
}

func NewGethEth1

func NewGethEth1(networks []string, chainConfig *config.EthereumChainConfig, opts ...EnvComponentOption) *Geth

NewGethEth1 starts a new Geth Eth1 node running in Docker

func NewGethEth2

func NewGethEth2(networks []string, chainConfig *config.EthereumChainConfig, generatedDataHostDir, generatedDataContainerDir string, consensusLayer config.ConsensusLayer, opts ...EnvComponentOption) (*Geth, error)

NewGethEth2 starts a new Geth Eth2 node running in Docker

func (*Geth) GetConsensusMechanism added in v1.50.20

func (g *Geth) GetConsensusMechanism() ConsensusMechanism

GetConsensusMechanism returns the consensus mechanism used by the Geth instance. It determines whether the Ethereum version is Eth1 or not, returning either Proof of Authority (PoA) or Proof of Stake (PoS) accordingly. This is useful for understanding the underlying protocol.

func (*Geth) GetContainer

func (g *Geth) GetContainer() *tc.Container

GetContainer returns a pointer to the container associated with the Geth instance. This function is useful for accessing the container's properties and methods in a seamless manner.

func (*Geth) GetContainerName

func (g *Geth) GetContainerName() string

GetContainerName returns the name of the container associated with the Geth instance. This function is useful for identifying and managing the container in a Docker environment.

func (*Geth) GetEthereumVersion

func (g *Geth) GetEthereumVersion() config_types.EthereumVersion

GetEthereumVersion returns the current Ethereum version of the Geth instance. This information is essential for determining the appropriate execution URL and consensus mechanism.

func (*Geth) GetExternalExecutionURL

func (g *Geth) GetExternalExecutionURL() string

GetExternalExecutionURL returns the external execution URL for the Geth instance. It panics if the Ethereum version is Eth1, as Eth1 nodes do not support execution URLs.

func (*Geth) GetExternalHttpUrl

func (g *Geth) GetExternalHttpUrl() string

GetExternalHttpUrl returns the external HTTP URL for the Geth client. This URL is used to interact with the Ethereum network externally, enabling communication with other services or clients.

func (*Geth) GetExternalWsUrl

func (g *Geth) GetExternalWsUrl() string

GetExternalWsUrl returns the external WebSocket URL for the Geth client. This URL is essential for connecting to the Ethereum network via WebSocket.

func (*Geth) GetInternalExecutionURL

func (g *Geth) GetInternalExecutionURL() string

GetInternalExecutionURL returns the internal execution URL for the Ethereum client. It is used to retrieve the endpoint for executing transactions in Ethereum 2.0 environments. An error is raised if called on an Ethereum 1.0 node.

func (*Geth) GetInternalHttpUrl

func (g *Geth) GetInternalHttpUrl() string

GetInternalHttpUrl returns the internal HTTP URL of the Geth client. This URL is essential for connecting to the execution layer in a private network setup.

func (*Geth) GetInternalWsUrl

func (g *Geth) GetInternalWsUrl() string

GetInternalWsUrl returns the internal WebSocket URL for the Geth client. This URL is essential for establishing WebSocket connections to the Geth node, enabling real-time data streaming and event handling.

func (*Geth) StartContainer

func (g *Geth) StartContainer() (blockchain.EVMNetwork, error)

StartContainer initializes and starts a Geth container for Ethereum, returning the network configuration. It supports both Eth1 and Eth2 versions, setting up necessary URLs for communication with the blockchain.

func (*Geth) WaitUntilChainIsReady

func (g *Geth) WaitUntilChainIsReady(ctx context.Context, waitTime time.Duration) error

WaitUntilChainIsReady blocks until the Ethereum chain is ready for use, or returns an error if it times out. This function is essential for ensuring that the blockchain environment is fully operational before proceeding with further operations.

func (*Geth) WithTestInstance

func (g *Geth) WithTestInstance(t *testing.T) ExecutionClient

WithTestInstance sets up the execution client with a test logger and associates it with the provided testing context. This is useful for capturing logs during testing and ensuring that the client operates in a test environment.

type HTTPStrategy

type HTTPStrategy struct {
	Path               string
	Port               nat.Port
	RetryDelay         time.Duration
	ExpectedStatusCode int
	// contains filtered or unexported fields
}

func NewHTTPStrategy

func NewHTTPStrategy(path string, port nat.Port) *HTTPStrategy

NewHTTPStrategy initializes a new HTTP strategy for waiting on a service to become available. It sets the path, port, retry delay, expected status code, and timeout, allowing for flexible service readiness checks.

func (*HTTPStrategy) WaitUntilReady

func (w *HTTPStrategy) WaitUntilReady(ctx context.Context, target tcwait.StrategyTarget) (err error)

WaitUntilReady implements Strategy.WaitUntilReady

func (*HTTPStrategy) WithStatusCode

func (w *HTTPStrategy) WithStatusCode(statusCode int) *HTTPStrategy

WithStatusCode sets the expected HTTP status code for the HTTP strategy. This allows users to specify the desired response code to validate during service startup.

func (*HTTPStrategy) WithTimeout

func (w *HTTPStrategy) WithTimeout(timeout time.Duration) *HTTPStrategy

WithTimeout sets the timeout duration for HTTP requests. It returns the updated HTTPStrategy instance, allowing for method chaining.

type Kafka

type Kafka struct {
	EnvComponent
	TopicConfigs       []KafkaTopicConfig
	EnvVars            map[string]string
	BootstrapServerUrl string
	InternalUrl        string
	ExternalUrl        string
	// contains filtered or unexported fields
}

func NewKafka

func NewKafka(networks []string) *Kafka

NewKafka initializes a new Kafka instance with a unique container name and default environment variables. It sets up the necessary configurations for Kafka to operate within specified networks, making it easy to deploy and manage Kafka services in a containerized environment.

func (*Kafka) CreateLocalTopics

func (k *Kafka) CreateLocalTopics() error

CreateLocalTopics creates Kafka topics based on the provided configurations. It ensures that topics are only created if they do not already exist, and logs the creation details for each topic. This function is useful for initializing Kafka environments with predefined topic settings.

func (*Kafka) StartContainer

func (k *Kafka) StartContainer() error

StartContainer initializes and starts a Kafka container with specified environment variables. It sets internal and external URLs for the container and logs the startup process. This function is essential for setting up a Kafka instance for testing or development purposes.

func (*Kafka) WithContainerName

func (k *Kafka) WithContainerName(name string) *Kafka

WithContainerName sets the container name for the Kafka instance. It configures the internal and bootstrap server URLs based on the provided name, allowing for easy identification and connection to the Kafka service.

func (*Kafka) WithEnvVars

func (k *Kafka) WithEnvVars(envVars map[string]string) *Kafka

WithEnvVars merges the provided environment variables into the Kafka instance's existing environment variables. It allows customization of the Kafka container's configuration before starting it.

func (*Kafka) WithTestInstance

func (k *Kafka) WithTestInstance(t *testing.T) *Kafka

WithTestInstance configures the Kafka instance for testing by setting up a test logger. It returns the modified Kafka instance, allowing for easier testing and logging during unit tests.

func (*Kafka) WithTopics

func (k *Kafka) WithTopics(topics []KafkaTopicConfig) *Kafka

WithTopics sets the Kafka topic configurations for the Kafka instance. It returns the updated Kafka instance, allowing for method chaining.

func (*Kafka) WithZookeeper

func (k *Kafka) WithZookeeper(zookeeperUrl string) *Kafka

WithZookeeper sets the Zookeeper connection URL for the Kafka instance. It prepares the necessary environment variables and returns the updated Kafka instance.

type KafkaTopicConfig

type KafkaTopicConfig struct {
	TopicName     string `json:"topic_name"`
	Partitions    int    `json:"partitions"`
	Replication   int    `json:"replication"`
	CleanupPolicy string `json:"cleanup_policy"`
}

type Killgrave

type Killgrave struct {
	EnvComponent
	ExternalEndpoint string
	InternalPort     string
	InternalEndpoint string
	// contains filtered or unexported fields
}

func NewKillgrave

func NewKillgrave(networks []string, impostersDirectoryPath string, opts ...EnvComponentOption) *Killgrave

NewKillgrave initializes a new Killgrave instance with specified networks and imposters directory. It sets default configurations and allows for optional environment component modifications. This function is useful for creating a Killgrave service for testing and simulating APIs.

func (*Killgrave) AddImposter

func (k *Killgrave) AddImposter(imposters []KillgraveImposter) error

AddImposter adds an imposter to the killgrave container

func (*Killgrave) GetReceivedRequests

func (k *Killgrave) GetReceivedRequests() ([]RequestData, error)

GetReceivedRequests retrieves and parses request data from a log file. It ensures all requests are written before reading and returns a slice of RequestData along with any encountered errors. This function is useful for accessing logged request information in a structured format.

func (*Killgrave) SetAdapterBasedAnyValuePath

func (k *Killgrave) SetAdapterBasedAnyValuePath(path string, methods []string, v interface{}) error

SetAdapterBasedAnyValuePath sets a path to return a value as though it was from an adapter

func (*Killgrave) SetAdapterBasedIntValuePath

func (k *Killgrave) SetAdapterBasedIntValuePath(path string, methods []string, v int) error

SetAdapterBasedAnyValuePathObject sets a path to return a value as though it was from an adapter

func (*Killgrave) SetAnyValueResponse

func (k *Killgrave) SetAnyValueResponse(path string, methods []string, v interface{}) error

SetAnyValueResponse sets a JSON-encoded response for a specified path and HTTP methods. It marshals the provided value into JSON format and updates the response headers accordingly. This function is useful for configuring dynamic API responses in a flexible manner.

func (*Killgrave) SetStringValuePath

func (k *Killgrave) SetStringValuePath(path string, methods []string, headers map[string]string, v string) error

SetStringValuePath sets a path to return a string value

func (*Killgrave) StartContainer

func (k *Killgrave) StartContainer() error

StartContainer initializes and starts the Killgrave container, setting up imposters and request dumping. It also configures cleanup for the container and logs the external and internal endpoints for access.

func (*Killgrave) WithTestInstance

func (k *Killgrave) WithTestInstance(t *testing.T) *Killgrave

WithTestInstance sets up a Killgrave instance for testing by assigning a test logger and the testing context. This allows for better logging during tests and facilitates easier debugging.

type KillgraveAdapterResponse

type KillgraveAdapterResponse struct {
	Id    string                 `json:"id"`
	Data  KillgraveAdapterResult `json:"data"`
	Error interface{}            `json:"error"`
}

AdapterResponse represents a response from an adapter

type KillgraveAdapterResult

type KillgraveAdapterResult struct {
	Result interface{} `json:"result"`
}

AdapterResult represents an int result for an adapter

type KillgraveImposter

type KillgraveImposter struct {
	Request  KillgraveRequest  `json:"request"`
	Response KillgraveResponse `json:"response"`
}

Imposter define an imposter structure

type KillgraveRequest

type KillgraveRequest struct {
	Method     string             `json:"method"`
	Endpoint   string             `json:"endpoint,omitempty"`
	SchemaFile *string            `json:"schemaFile,omitempty"`
	Params     *map[string]string `json:"params,omitempty"`
	Headers    *map[string]string `json:"headers"`
}

type KillgraveResponse

type KillgraveResponse struct {
	Status   int                     `json:"status"`
	Body     string                  `json:"body,omitempty"`
	BodyFile *string                 `json:"bodyFile,omitempty"`
	Headers  *map[string]string      `json:"headers,omitempty"`
	Delay    *KillgraveResponseDelay `json:"delay,omitempty"`
}

Response represent the structure of real response

type KillgraveResponseDelay

type KillgraveResponseDelay struct {
	Delay  int64 `json:"delay,omitempty"`
	Offset int64 `json:"offset,omitempty"`
}

ResponseDelay represent time delay before server responds.

type MockServer

type MockServer struct {
	EnvComponent
	Client           *ctfClient.MockserverClient
	Endpoint         string
	InternalEndpoint string
	EAMockUrls       []*url.URL
	// contains filtered or unexported fields
}

func NewMockServer

func NewMockServer(networks []string, opts ...EnvComponentOption) *MockServer

NewMockServer creates a new instance of MockServer with specified networks and options. It initializes the server with a unique container name and a default startup timeout. This function is useful for testing decentralized applications in a controlled environment.

func (*MockServer) SetExternalAdapterMocks

func (ms *MockServer) SetExternalAdapterMocks(count int) error

SetExternalAdapterMocks configures a specified number of mock external adapter endpoints. It generates unique paths for each adapter and stores their URLs for later use. This function is useful for testing scenarios that require multiple external adapter interactions.

func (*MockServer) StartContainer

func (ms *MockServer) StartContainer() error

StartContainer initializes and starts a MockServer container. It sets up logging, retrieves the container request, and establishes endpoints for communication. This function is essential for testing environments that require a mock server instance.

func (*MockServer) WithTestInstance

func (ms *MockServer) WithTestInstance(t *testing.T) *MockServer

WithTestInstance configures the MockServer with a test logger and test context. It returns the updated MockServer instance for use in testing scenarios.

type Nethermind

type Nethermind struct {
	EnvComponent
	ExternalHttpUrl      string
	InternalHttpUrl      string
	ExternalWsUrl        string
	InternalWsUrl        string
	InternalExecutionURL string
	ExternalExecutionURL string
	// contains filtered or unexported fields
}

func NewNethermindEth1

func NewNethermindEth1(networks []string, chainConfig *config.EthereumChainConfig, opts ...EnvComponentOption) (*Nethermind, error)

NewNethermindEth1 starts a new Nethermind Eth1 node running in Docker

func NewNethermindEth2

func NewNethermindEth2(networks []string, chainConfig *config.EthereumChainConfig, generatedDataHostDir, generatedDataContainerDir string, consensusLayer config.ConsensusLayer, opts ...EnvComponentOption) (*Nethermind, error)

NewNethermindEth2 starts a new Nethermin Eth2 node running in Docker

func (*Nethermind) GetConsensusMechanism added in v1.50.20

func (g *Nethermind) GetConsensusMechanism() ConsensusMechanism

GetConsensusMechanism returns the consensus mechanism used by the Nethermind instance. It determines whether the Ethereum version is Eth1 or not, returning either Proof of Authority (PoA) or Proof of Stake (PoS) accordingly. This is useful for understanding the network's validation method.

func (*Nethermind) GetContainer

func (g *Nethermind) GetContainer() *tc.Container

GetContainer returns a pointer to the Container associated with the Nethermind instance. This function is useful for accessing the container's properties and methods in a Dockerized environment.

func (*Nethermind) GetContainerName

func (g *Nethermind) GetContainerName() string

GetContainerName returns the name of the container associated with the Nethermind instance. This function is useful for identifying and managing the container in a Docker environment.

func (*Nethermind) GetEthereumVersion

func (g *Nethermind) GetEthereumVersion() config_types.EthereumVersion

GetEthereumVersion returns the current Ethereum version of the Nethermind instance. This information is crucial for determining the appropriate execution URLs and consensus mechanisms.

func (*Nethermind) GetExternalExecutionURL

func (g *Nethermind) GetExternalExecutionURL() string

GetExternalExecutionURL returns the external execution URL for the Nethermind node. It panics if the node is running on Ethereum version 1, as it does not support execution URLs.

func (*Nethermind) GetExternalHttpUrl

func (g *Nethermind) GetExternalHttpUrl() string

GetExternalHttpUrl returns the external HTTP URL for the Nethermind client. This URL is used to interact with the Nethermind execution layer over HTTP.

func (*Nethermind) GetExternalWsUrl

func (g *Nethermind) GetExternalWsUrl() string

GetExternalWsUrl returns the external WebSocket URL for the Nethermind client. This URL is essential for connecting to the Nethermind execution layer from external services.

func (*Nethermind) GetInternalExecutionURL

func (g *Nethermind) GetInternalExecutionURL() string

GetInternalExecutionURL returns the internal execution URL for the Ethereum client. It is used to retrieve the endpoint for executing transactions in a network that supports it. If the client is an Eth1 node, it will panic as Eth1 does not have an execution URL.

func (*Nethermind) GetInternalHttpUrl

func (g *Nethermind) GetInternalHttpUrl() string

GetInternalHttpUrl returns the internal HTTP URL of the Nethermind client. This URL is used to communicate with the execution layer in a secure manner.

func (*Nethermind) GetInternalWsUrl

func (g *Nethermind) GetInternalWsUrl() string

GetInternalWsUrl returns the internal WebSocket URL for the Nethermind client. This URL is essential for establishing WebSocket connections to the execution layer.

func (*Nethermind) StartContainer

func (g *Nethermind) StartContainer() (blockchain.EVMNetwork, error)

StartContainer initializes and starts a Nethermind container for Ethereum execution. It configures network settings based on the Ethereum version and returns the network configuration along with any errors encountered during the process.

func (*Nethermind) WaitUntilChainIsReady

func (g *Nethermind) WaitUntilChainIsReady(ctx context.Context, waitTime time.Duration) error

WaitUntilChainIsReady blocks until the Ethereum chain is fully operational or the specified wait time elapses. It is useful for ensuring that the blockchain client is ready for transactions or queries before proceeding.

func (*Nethermind) WithTestInstance

func (g *Nethermind) WithTestInstance(t *testing.T) ExecutionClient

WithTestInstance sets up the execution client with a test logger and test context. This is useful for running tests with specific logging and context requirements.

type PostgresDb

type PostgresDb struct {
	EnvComponent
	User         string   `json:"user"`
	Password     string   `json:"password"`
	DbName       string   `json:"dbName"`
	InternalPort string   `json:"internalPort"`
	ExternalPort string   `json:"-"`
	InternalURL  *url.URL `json:"-"`
	ExternalURL  *url.URL `json:"-"`
	// contains filtered or unexported fields
}

func NewPostgresDb

func NewPostgresDb(networks []string, opts ...PostgresDbOption) (*PostgresDb, error)

NewPostgresDb initializes a new Postgres database instance with specified networks and options. It sets up the container environment and default configurations, returning the PostgresDb object for use in applications requiring a Postgres database connection.

func (*PostgresDb) ExecPgDumpFromContainer

func (pg *PostgresDb) ExecPgDumpFromContainer(writer io.Writer) error

ExecPgDumpFromContainer executed pg_dump from inside the container. It dumps it to temporary file inside the container and then writes to the writer.

func (*PostgresDb) ExecPgDumpFromLocal

func (pg *PostgresDb) ExecPgDumpFromLocal(stdout io.Writer) error

ExecPgDumpFromLocal executes pg_dump from local machine by connecting to external Postgres port. For it to work pg_dump needs to be installed on local machine.

func (*PostgresDb) RestartContainer

func (pg *PostgresDb) RestartContainer() error

RestartContainer restarts the PostgreSQL database container, ensuring it is running with the latest configuration. This function is useful for applying changes or recovering from issues without needing to manually stop and start the container.

func (*PostgresDb) StartContainer

func (pg *PostgresDb) StartContainer() error

StartContainer initializes and starts a PostgreSQL database container. It ensures the container is ready for use, providing both internal and external connection URLs. This function is essential for setting up a database environment in testing or development scenarios.

func (*PostgresDb) WithTestInstance

func (pg *PostgresDb) WithTestInstance(t *testing.T) *PostgresDb

WithTestInstance sets up a PostgresDb instance for testing, initializing a test logger and associating it with the provided testing context. This allows for better logging during tests.

type PostgresDbOption

type PostgresDbOption = func(c *PostgresDb)

func WithContainerEnv

func WithContainerEnv(key, value string) PostgresDbOption

WithContainerEnv sets an environment variable for the Postgres database container. It allows users to configure the container's environment by providing a key-value pair.

func WithPostgresDbContainerName

func WithPostgresDbContainerName(name string) PostgresDbOption

Sets custom container name if name is not empty

func WithPostgresDbName

func WithPostgresDbName(name string) PostgresDbOption

WithPostgresDbName sets the database name for a PostgresDb instance. It returns a PostgresDbOption that can be used to configure the database connection.

func WithPostgresImageName

func WithPostgresImageName(imageName string) PostgresDbOption

WithPostgresImageName sets the Docker image name for the Postgres database container. It allows customization of the container image used, enabling users to specify a preferred version or variant.

func WithPostgresImageVersion

func WithPostgresImageVersion(version string) PostgresDbOption

WithPostgresImageVersion sets the PostgreSQL container image version for the database. It allows customization of the database version used in the container, enhancing flexibility for development and testing environments.

type PrysmBeaconChain

type PrysmBeaconChain struct {
	EnvComponent
	InternalBeaconRpcProvider string
	InternalQueryRpcUrl       string
	ExternalBeaconRpcProvider string
	ExternalQueryRpcUrl       string
	// contains filtered or unexported fields
}

func NewPrysmBeaconChain

func NewPrysmBeaconChain(networks []string, chainConfig *config.EthereumChainConfig, generatedDataHostDir, generatedDataContainerDir, gethExecutionURL string, baseEthereumFork ethereum.Fork, opts ...EnvComponentOption) (*PrysmBeaconChain, error)

NewPrysmBeaconChain initializes a new Prysm beacon chain instance with the specified network configurations and parameters. It is used to set up a beacon chain for Ethereum 2.0, enabling users to run and manage a consensus layer node.

func (*PrysmBeaconChain) StartContainer

func (g *PrysmBeaconChain) StartContainer() error

StartContainer initializes and starts the Prysm Beacon Chain container. It sets up the necessary RPC endpoints and logs the container's status. This function is essential for deploying a Prysm-based Ethereum 2.0 beacon chain in a Docker environment.

func (*PrysmBeaconChain) WithTestInstance

func (g *PrysmBeaconChain) WithTestInstance(t *testing.T) *PrysmBeaconChain

WithTestInstance sets up the PrysmBeaconChain for testing by assigning a test logger and the testing context. This allows for better logging and error tracking during test execution.

type PrysmValidator

type PrysmValidator struct {
	EnvComponent
	// contains filtered or unexported fields
}

func NewPrysmValidator

func NewPrysmValidator(networks []string, chainConfig *config.EthereumChainConfig, generatedDataHostDir, generatedDataContainerDir, valKeysDir, internalBeaconRpcProvider string, baseEthereumFork ethereum.Fork, opts ...EnvComponentOption) (*PrysmValidator, error)

NewPrysmValidator initializes a new Prysm validator instance with the specified network configurations and settings. It is used to set up a validator for Ethereum's consensus layer, ensuring proper integration with the blockchain environment.

func (*PrysmValidator) StartContainer

func (g *PrysmValidator) StartContainer() error

StartContainer initializes and starts the Prysm validator container. It handles the setup and logging, ensuring the container is ready for use in Ethereum network operations.

func (*PrysmValidator) WithTestInstance

func (g *PrysmValidator) WithTestInstance(t *testing.T) *PrysmValidator

WithTestInstance sets up the PrysmValidator with a test logger and the provided testing context. This allows for easier testing and debugging of the validator's behavior during unit tests.

type RequestData

type RequestData struct {
	Method string              `json:"method"`
	Host   string              `json:"host"`
	URL    string              `json:"url"`
	Header map[string][]string `json:"header"`
	Body   string              `json:"body"`
}

type Reth

type Reth struct {
	EnvComponent
	ExternalHttpUrl      string
	InternalHttpUrl      string
	ExternalWsUrl        string
	InternalWsUrl        string
	InternalExecutionURL string
	ExternalExecutionURL string
	// contains filtered or unexported fields
}

func NewRethEth2

func NewRethEth2(networks []string, chainConfig *config.EthereumChainConfig, generatedDataHostDir, generatedDataContainerDir string, consensusLayer config.ConsensusLayer, opts ...EnvComponentOption) (*Reth, error)

NewRethEth2 starts a new Reth Eth2 node running in Docker

func (*Reth) GetConsensusMechanism added in v1.50.20

func (g *Reth) GetConsensusMechanism() ConsensusMechanism

GetConsensusMechanism returns the consensus mechanism used by the Ethereum network. It identifies whether the network is operating on Proof of Work (PoW) or Proof of Stake (PoS) based on the current Ethereum version, aiding in understanding network dynamics.

func (*Reth) GetContainer

func (g *Reth) GetContainer() *tc.Container

GetContainer returns a pointer to the container associated with the Reth instance. This function is useful for accessing the container's properties and methods in order to manage or interact with the execution environment.

func (*Reth) GetContainerName

func (g *Reth) GetContainerName() string

GetContainerName returns the name of the container associated with the Reth instance. This function is useful for identifying and managing the container in a Docker environment.

func (*Reth) GetEthereumVersion

func (g *Reth) GetEthereumVersion() config_types.EthereumVersion

GetEthereumVersion returns the current Ethereum version of the Reth instance. This information is essential for determining compatibility and functionality with various Ethereum features and services.

func (*Reth) GetExternalExecutionURL

func (g *Reth) GetExternalExecutionURL() string

GetExternalExecutionURL returns the external execution URL for the Reth instance. It panics if the Ethereum version is Eth1, as Eth1 nodes do not support execution URLs.

func (*Reth) GetExternalHttpUrl

func (g *Reth) GetExternalHttpUrl() string

GetExternalHttpUrl returns the external HTTP URL for the Reth execution client. This URL is useful for connecting to the client from external applications or services.

func (*Reth) GetExternalWsUrl

func (g *Reth) GetExternalWsUrl() string

GetExternalWsUrl returns the external WebSocket URL for the Reth execution client. This URL is essential for connecting to the client for real-time data and event subscriptions.

func (*Reth) GetInternalExecutionURL

func (g *Reth) GetInternalExecutionURL() string

GetInternalExecutionURL returns the internal execution URL for the Ethereum client. It is used to retrieve the endpoint for interacting with the execution layer, ensuring compatibility with Ethereum 2.0 clients.

func (*Reth) GetInternalHttpUrl

func (g *Reth) GetInternalHttpUrl() string

GetInternalHttpUrl returns the internal HTTP URL of the execution client. This URL is essential for establishing communication with the client in a secure manner.

func (*Reth) GetInternalWsUrl

func (g *Reth) GetInternalWsUrl() string

GetInternalWsUrl returns the internal WebSocket URL for the Reth execution client. This URL is essential for establishing WebSocket connections to the client for real-time data streaming.

func (*Reth) StartContainer

func (g *Reth) StartContainer() (blockchain.EVMNetwork, error)

StartContainer initializes and starts a Reth execution client container. It returns the configured EVM network details or an error if the process fails. This function is essential for setting up a local Ethereum environment for testing or development.

func (*Reth) WaitUntilChainIsReady

func (g *Reth) WaitUntilChainIsReady(ctx context.Context, waitTime time.Duration) error

WaitUntilChainIsReady blocks until the Ethereum chain is ready for use, waiting for the first block to be committed if necessary. This function is essential for ensuring that the blockchain environment is fully operational before proceeding with further operations.

func (*Reth) WithTestInstance

func (g *Reth) WithTestInstance(t *testing.T) ExecutionClient

WithTestInstance sets up the execution client with a test logger and the provided testing context. This is useful for integrating testing frameworks with the execution client, enabling better logging and error tracking during tests.

type RpcProvider

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

RpcProvider holds all necessary URLs to connect to a simulated chain or a real RPC provider connected to a live chain maybe only store ports here and depending on where the test is executed return different URLs? maybe 3 different constructors for each "perspective"? (docker, k8s with local runner, k8s with remote runner)

func NewRPCProvider

func NewRPCProvider(
	privateHttpUrls,
	privateWsUrls,
	publiclHttpUrls,
	publicWsUrls []string,
) RpcProvider

NewRPCProvider creates a new RpcProvider, and should only be used for custom network connections e.g. to a live testnet chain

func (*RpcProvider) PrivateHttpUrls

func (s *RpcProvider) PrivateHttpUrls() []string

PrivateHttpUrls returns a slice of private HTTP URLs used by the RPC provider. This function is useful for accessing internal endpoints securely in a decentralized application.

func (*RpcProvider) PrivateWsUrsl

func (s *RpcProvider) PrivateWsUrsl() []string

PrivateWsUrls returns a slice of private WebSocket URLs. This function is useful for clients needing to connect to private WebSocket endpoints for secure communication.

func (*RpcProvider) PublicHttpUrls

func (s *RpcProvider) PublicHttpUrls() []string

PublicHttpUrls returns a slice of public HTTP URLs for the RPC provider. This function is useful for clients needing to connect to the provider's services over HTTP.

func (*RpcProvider) PublicWsUrls

func (s *RpcProvider) PublicWsUrls() []string

PublicWsUrls returns a slice of public WebSocket URLs for the RPC provider. This function is useful for clients needing to connect to the provider's WebSocket endpoints for real-time data.

type SchemaRegistry

type SchemaRegistry struct {
	EnvComponent
	EnvVars     map[string]string
	InternalUrl string
	ExternalUrl string
	// contains filtered or unexported fields
}

func NewSchemaRegistry

func NewSchemaRegistry(networks []string) *SchemaRegistry

NewSchemaRegistry initializes a new SchemaRegistry instance with a unique container name and specified networks. It sets default environment variables and a startup timeout, making it suitable for managing schema registries in decentralized applications.

func (*SchemaRegistry) StartContainer

func (r *SchemaRegistry) StartContainer() error

StartContainer initializes and starts a Schema Registry container. It sets up the necessary environment variables and logs the internal and external URLs for accessing the container. This function is essential for users needing a running instance of Schema Registry for testing or development purposes.

func (*SchemaRegistry) WithContainerName

func (r *SchemaRegistry) WithContainerName(name string) *SchemaRegistry

WithContainerName sets the container name for the SchemaRegistry instance. This allows users to customize the naming of the container for better organization and identification within their application. It returns the updated SchemaRegistry.

func (*SchemaRegistry) WithEnvVars

func (r *SchemaRegistry) WithEnvVars(envVars map[string]string) *SchemaRegistry

WithEnvVars merges the provided environment variables into the SchemaRegistry's existing set. It allows for dynamic configuration of the Schema Registry based on the specified environment settings.

func (*SchemaRegistry) WithKafka

func (r *SchemaRegistry) WithKafka(kafkaUrl string) *SchemaRegistry

WithKafka sets the Kafka bootstrap servers for the Schema Registry using the provided URL. It returns the updated SchemaRegistry instance with the new environment variables applied.

func (*SchemaRegistry) WithTestInstance

func (r *SchemaRegistry) WithTestInstance(t *testing.T) *SchemaRegistry

WithTestInstance sets up a SchemaRegistry instance for testing purposes. It initializes the logger with a test logger and associates the testing context, allowing for better logging and error tracking during tests.

type UnsupportedVersion

type UnsupportedVersion struct {
	DockerImage string
	Reason      string
}

type ValKeysGenerator

type ValKeysGenerator struct {
	EnvComponent
	// contains filtered or unexported fields
}

func NewValKeysGeneretor

func NewValKeysGeneretor(chainConfig *config.EthereumChainConfig, valKeysHostDataDir string, opts ...EnvComponentOption) (*ValKeysGenerator, error)

NewValKeysGeneretor initializes a ValKeysGenerator for managing validator key generation in a specified Ethereum environment. It sets up the necessary container configuration and options, returning the generator instance or an error if initialization fails.

func (*ValKeysGenerator) StartContainer

func (g *ValKeysGenerator) StartContainer() error

StartContainer initializes and starts the validation keys generation container. It ensures the container is ready for use, logging the start event, and returns any errors encountered during the process.

func (*ValKeysGenerator) WithTestInstance

func (g *ValKeysGenerator) WithTestInstance(t *testing.T) *ValKeysGenerator

WithTestInstance sets up a test logger and associates it with the ValKeysGenerator instance. This is useful for capturing log output during testing, ensuring that logs are directed to the test context.

type WebSocketStrategy

type WebSocketStrategy struct {
	Port       nat.Port
	RetryDelay time.Duration
	// contains filtered or unexported fields
}

func NewWebSocketStrategy

func NewWebSocketStrategy(port nat.Port, l zerolog.Logger) *WebSocketStrategy

NewWebSocketStrategy initializes a WebSocket strategy for monitoring service readiness. It sets the port and defines retry behavior, making it useful for ensuring services are operational before proceeding.

func (*WebSocketStrategy) WaitUntilReady

func (w *WebSocketStrategy) WaitUntilReady(ctx context.Context, target tcwait.StrategyTarget) (err error)

WaitUntilReady waits for the WebSocket service to become available by repeatedly attempting to connect. It returns an error if the connection cannot be established within the specified timeout.

func (*WebSocketStrategy) WithTimeout

func (w *WebSocketStrategy) WithTimeout(timeout time.Duration) *WebSocketStrategy

WithTimeout sets the timeout duration for the WebSocket strategy. It allows users to specify how long to wait for a response before timing out, enhancing control over connection behavior in network operations.

type Zookeeper

type Zookeeper struct {
	EnvComponent
	InternalUrl string
	// contains filtered or unexported fields
}

func NewZookeeper

func NewZookeeper(networks []string) *Zookeeper

NewZookeeper creates a new Zookeeper instance with a unique container name and specified networks. It initializes default hooks and sets a startup timeout, making it suitable for managing distributed systems.

func (*Zookeeper) StartContainer

func (z *Zookeeper) StartContainer() error

StartContainer initializes and starts a Zookeeper container. It configures logging, handles errors, and sets the internal URL for the container. This function is essential for setting up a Zookeeper instance in a test environment.

func (*Zookeeper) WithContainerName

func (z *Zookeeper) WithContainerName(name string) *Zookeeper

WithContainerName sets the container name for the Zookeeper instance. It returns the updated Zookeeper instance, allowing for method chaining.

func (*Zookeeper) WithTestInstance

func (z *Zookeeper) WithTestInstance(t *testing.T) *Zookeeper

WithTestInstance configures the Zookeeper instance for testing by setting up a test logger. It returns the modified Zookeeper instance, allowing for easier testing and logging during test execution.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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