e2e

package
v1.14.1-db-metrics-fix Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: BSD-3-Clause Imports: 31 Imported by: 20

Documentation

Index

Constants

View Source
const (
	DefaultTimeout = tests.DefaultTimeout

	DefaultPollingInterval = tmpnet.DefaultPollingInterval

	// Setting this env will disable post-test bootstrap
	// checks. Useful for speeding up iteration during test
	// development.
	SkipBootstrapChecksEnvName = "E2E_SKIP_BOOTSTRAP_CHECKS"

	DefaultValidatorStartTimeDiff = tmpnet.DefaultValidatorStartTimeDiff

	DefaultGasLimit = uint64(21000) // Standard gas limit

	// Directory used to store private networks (specific to a single test)
	// under the shared network dir.
	PrivateNetworksDirName = "private_networks"
)
View Source
const (

	// Label for filtering a test that is not primarily a C-Chain test
	// but nonetheless uses the C-Chain. Intended to support
	// execution of all C-Chain tests by the coreth repo in an e2e job.
	UsesCChainLabel = "uses-c"
)

Variables

View Source
var EmitMetricsLink bool

Whether a spec-scoped metrics link should be emitted after the current spec finishes executing.

Functions

func AddEphemeralNode

func AddEphemeralNode(tc tests.TestContext, network *tmpnet.Network, node *tmpnet.Node) *tmpnet.Node

Adds an ephemeral node intended to be used by a single test.

func CheckBootstrapIsPossible

func CheckBootstrapIsPossible(tc tests.TestContext, network *tmpnet.Network) *tmpnet.Node

Verify that a new node can bootstrap into the network. If the check wasn't skipped, the node will be returned to the caller.

func DescribeCChain

func DescribeCChain(text string, args ...interface{}) bool

DescribeCChain annotates the tests for C-Chain.

func DescribePChain

func DescribePChain(text string, args ...interface{}) bool

DescribePChain annotates the tests for P-Chain.

func DescribeXChain

func DescribeXChain(text string, args ...interface{}) bool

DescribeXChain annotates the tests for X-Chain.

func DescribeXChainSerial

func DescribeXChainSerial(text string, args ...interface{}) bool

DescribeXChainSerial annotates serial tests for X-Chain.

func ExecuteAPITest

func ExecuteAPITest(apiTest APITestFunction)

ExecuteAPITest executes a test whose primary dependency is being able to access the API of one or more avalanchego nodes.

func GetRepoRootPath added in v1.11.12

func GetRepoRootPath(suffix string) (string, error)

GetRepoRootPath strips the provided suffix from the current working directory. If the test binary is executed from the root of the repo, the result will be the repo root.

func GetWalletBalances added in v1.11.12

func GetWalletBalances(tc tests.TestContext, wallet *primary.Wallet) (uint64, uint64)

GetWalletBalances retrieves the X-Chain and P-Chain balances of the provided wallet.

func InitSharedTestEnvironment

func InitSharedTestEnvironment(tc tests.TestContext, envBytes []byte)

func NewEthClient

func NewEthClient(tc tests.TestContext, nodeURI tmpnet.NodeURI) *ethclient.Client

Create a new eth client targeting the specified node URI.

func NewPChainFeeCalculatorFromContext added in v1.11.11

func NewPChainFeeCalculatorFromContext(context *builder.Context) fee.Calculator

NewPChainFeeCalculatorFromContext returns either a static or dynamic fee calculator depending on the provided context.

func NewPrivateKey added in v1.11.11

func NewPrivateKey(tc tests.TestContext) *secp256k1.PrivateKey

NewPrivateKey returns a new private key.

func NewWallet

func NewWallet(tc tests.TestContext, keychain *secp256k1fx.Keychain, nodeURI tmpnet.NodeURI) *primary.Wallet

Create a new wallet for the provided keychain against the specified node URI.

func OutputWalletBalances added in v1.11.12

func OutputWalletBalances(tc tests.TestContext, wallet *primary.Wallet)

OutputWalletBalances outputs the X-Chain and P-Chain balances of the provided wallet.

func SendEthTransaction

func SendEthTransaction(tc tests.TestContext, ethClient *ethclient.Client, signedTx *types.Transaction) *types.Receipt

Sends an eth transaction and waits for the transaction receipt from the execution of the transaction.

func SetCheckCollectionFlags added in v1.13.1

func SetCheckCollectionFlags(checkMetricsCollected *bool, checkLogsCollected *bool)

func StartNetwork added in v1.10.18

func StartNetwork(
	tc tests.TestContext,
	network *tmpnet.Network,
	rootNetworkDir string,
	shutdownDelay time.Duration,
	networkCmd NetworkCmd,
)

Start a temporary network with the provided avalanchego binary.

func SuggestGasPrice

func SuggestGasPrice(tc tests.TestContext, ethClient *ethclient.Client) *big.Int

Determines the suggested gas price for the configured client that will maximize the chances of transaction acceptance.

func WaitForHealthy

func WaitForHealthy(t require.TestingT, node *tmpnet.Node)

Wait for the given node to report healthy.

func WithSuggestedGasPrice

func WithSuggestedGasPrice(tc tests.TestContext, ethClient *ethclient.Client) common.Option

Helper simplifying use via an option of a gas price appropriate for testing.

Types

type APITestFunction

type APITestFunction func(tc tests.TestContext, wallet primary.Wallet, ownerAddress ids.ShortID)

TODO(marun) What else does a test need? e.g. node URIs?

type DefaultOption added in v1.13.3

type DefaultOption func(*DefaultOptions)

func WithDefaultNodeCount added in v1.13.3

func WithDefaultNodeCount(nodeCount int) DefaultOption

func WithDefaultOwner added in v1.13.3

func WithDefaultOwner(owner string) DefaultOption

type DefaultOptions added in v1.13.3

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

func (*DefaultOptions) NodeCount added in v1.13.3

func (d *DefaultOptions) NodeCount() int

func (*DefaultOptions) Owner added in v1.13.3

func (d *DefaultOptions) Owner() string

type FlagVars

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

func RegisterFlags

func RegisterFlags(ops ...DefaultOption) *FlagVars

func (*FlagVars) ActivateGranite added in v1.13.1

func (v *FlagVars) ActivateGranite() bool

func (*FlagVars) CheckLogsCollected added in v1.13.1

func (v *FlagVars) CheckLogsCollected() bool

func (*FlagVars) CheckMetricsCollected added in v1.13.1

func (v *FlagVars) CheckMetricsCollected() bool

func (*FlagVars) NetworkCmd added in v1.13.1

func (v *FlagVars) NetworkCmd() (NetworkCmd, error)

func (*FlagVars) NetworkDir added in v1.10.17

func (v *FlagVars) NetworkDir() string

func (*FlagVars) NetworkOwner added in v1.13.1

func (v *FlagVars) NetworkOwner() string

func (*FlagVars) NetworkShutdownDelay added in v1.11.3

func (v *FlagVars) NetworkShutdownDelay() time.Duration

func (*FlagVars) NodeCount added in v1.11.6

func (v *FlagVars) NodeCount() (int, error)

func (*FlagVars) NodeRuntimeConfig added in v1.13.1

func (v *FlagVars) NodeRuntimeConfig() (*tmpnet.NodeRuntimeConfig, error)

func (*FlagVars) RootNetworkDir added in v1.13.1

func (v *FlagVars) RootNetworkDir() string

func (*FlagVars) StartLogsCollector added in v1.13.1

func (v *FlagVars) StartLogsCollector() bool

func (*FlagVars) StartMetricsCollector added in v1.13.1

func (v *FlagVars) StartMetricsCollector() bool

type GinkgoTestContext added in v1.11.11

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

func NewEventHandlerTestContext added in v1.13.0

func NewEventHandlerTestContext() *GinkgoTestContext

NewEventHandlerTestContext provides a logger with full output to account for the limited context otherwise provided in an event handler e.g. SynchronizedBeforeSuite.

func NewTestContext added in v1.11.11

func NewTestContext() *GinkgoTestContext

NewTestContext provides a logger with limited output to account for the context already provided by ginkgo for test logging.

func (*GinkgoTestContext) By added in v1.11.11

func (*GinkgoTestContext) By(text string, callback ...func())

func (*GinkgoTestContext) Cleanup added in v1.11.11

func (*GinkgoTestContext) Cleanup()

func (*GinkgoTestContext) ContextWithTimeout added in v1.11.11

func (tc *GinkgoTestContext) ContextWithTimeout(duration time.Duration) context.Context

Helper simplifying use of a timed context by canceling the context on ginkgo teardown.

func (*GinkgoTestContext) DefaultContext added in v1.11.11

func (tc *GinkgoTestContext) DefaultContext() context.Context

Helper simplifying use of a timed context configured with the default timeout.

func (*GinkgoTestContext) DeferCleanup added in v1.11.11

func (*GinkgoTestContext) DeferCleanup(cleanup func())

func (*GinkgoTestContext) Errorf added in v1.11.11

func (*GinkgoTestContext) Errorf(format string, args ...interface{})

func (*GinkgoTestContext) Eventually added in v1.11.11

func (*GinkgoTestContext) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, msg string)

Re-implementation of testify/require.Eventually that is compatible with ginkgo. testify's version calls the condition function with a goroutine and ginkgo assertions don't work properly in goroutines.

func (*GinkgoTestContext) FailNow added in v1.11.11

func (*GinkgoTestContext) FailNow()

func (*GinkgoTestContext) GetDefaultContextParent

func (*GinkgoTestContext) GetDefaultContextParent() context.Context

func (*GinkgoTestContext) Log added in v1.12.0

func (tc *GinkgoTestContext) Log() logging.Logger

func (*GinkgoTestContext) WithDefaultContext added in v1.11.11

func (tc *GinkgoTestContext) WithDefaultContext() common.Option

Helper simplifying use via an option of a timed context configured with the default timeout.

type NetworkCmd added in v1.13.1

type NetworkCmd int
const (
	EmptyNetworkCmd NetworkCmd = iota
	StartNetworkCmd
	StopNetworkCmd
	RestartNetworkCmd
	ReuseNetworkCmd
)

type TestEnvironment

type TestEnvironment struct {
	// The parent directory of network directories
	RootNetworkDir string
	// The directory where the test network configuration is stored
	NetworkDir string
	// Pre-funded key for this ginkgo process
	PreFundedKey *secp256k1.PrivateKey
	// The duration to wait before shutting down private networks. A
	// non-zero value may be useful to ensure all metrics can be
	// scraped before shutdown.
	PrivateNetworkShutdownDelay time.Duration
	// contains filtered or unexported fields
}

func GetEnv added in v1.11.11

func GetEnv(tc tests.TestContext) *TestEnvironment

Retrieve the test environment configured with the provided test context.

func NewTestEnvironment

func NewTestEnvironment(tc tests.TestContext, flagVars *FlagVars, desiredNetwork *tmpnet.Network) *TestEnvironment

Initialize a new test environment with a shared network (either pre-existing or newly created).

func (*TestEnvironment) GetNetwork

func (te *TestEnvironment) GetNetwork() *tmpnet.Network

Retrieve the network to target for testing.

func (*TestEnvironment) GetRandomNodeURI

func (te *TestEnvironment) GetRandomNodeURI() tmpnet.NodeURI

Retrieve a random URI to naively attempt to spread API load across nodes.

func (*TestEnvironment) Marshal

func (te *TestEnvironment) Marshal() []byte

func (*TestEnvironment) NewKeychain

func (te *TestEnvironment) NewKeychain() *secp256k1fx.Keychain

Create a new keychain with the process's pre-funded key.

func (*TestEnvironment) StartPrivateNetwork added in v1.11.3

func (te *TestEnvironment) StartPrivateNetwork(network *tmpnet.Network)

Create a new private network that is not shared with other tests.

Jump to

Keyboard shortcuts

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