Documentation
¶
Index ¶
- Constants
- Variables
- func AddEphemeralNode(tc tests.TestContext, network *tmpnet.Network, node *tmpnet.Node) *tmpnet.Node
- func CheckBootstrapIsPossible(tc tests.TestContext, network *tmpnet.Network) *tmpnet.Node
- func DescribeCChain(text string, args ...interface{}) bool
- func DescribePChain(text string, args ...interface{}) bool
- func DescribeXChain(text string, args ...interface{}) bool
- func DescribeXChainSerial(text string, args ...interface{}) bool
- func ExecuteAPITest(apiTest APITestFunction)
- func GetLocalStakingAddress(tc tests.TestContext, node *tmpnet.Node) netip.AddrPort
- func GetLocalURI(tc tests.TestContext, node *tmpnet.Node) string
- func GetRepoRootPath(suffix string) (string, error)
- func GetWalletBalances(tc tests.TestContext, wallet *primary.Wallet) (uint64, uint64)
- func InitSharedTestEnvironment(tc tests.TestContext, envBytes []byte)
- func NewEthClient(tc tests.TestContext, nodeURI tmpnet.NodeURI) *ethclient.Client
- func NewPChainFeeCalculatorFromContext(context *builder.Context) fee.Calculator
- func NewPrivateKey(tc tests.TestContext) *secp256k1.PrivateKey
- func NewTestContext() tests.TestContext
- func NewWallet(tc tests.TestContext, keychain *secp256k1fx.Keychain, nodeURI tmpnet.NodeURI) *primary.Wallet
- func NewWalletWithContext(tc tests.TestContext, keychain *secp256k1fx.Keychain, nodeURI tmpnet.NodeURI) primary.Wallet
- func OutputWalletBalances(tc tests.TestContext, wallet *primary.Wallet)
- func SendEthTransaction(tc tests.TestContext, ethClient *ethclient.Client, signedTx *types.Transaction) *types.Receipt
- func SetCheckCollectionFlags(checkMetricsCollected *bool, checkLogsCollected *bool)
- func StartNetwork(tc tests.TestContext, network *tmpnet.Network, rootNetworkDir string, ...)
- func SuggestGasPrice(tc tests.TestContext, ethClient *ethclient.Client) *big.Int
- func WaitForHealthy(t require.TestingT, node *tmpnet.Node)
- func WithSuggestedGasPrice(tc tests.TestContext, ethClient *ethclient.Client) common.Option
- type APITestEnvironment
- type APITestFunction
- type DefaultOption
- type DefaultOptions
- type FlagVars
- func (v *FlagVars) ActivateGranite() bool
- func (v *FlagVars) CheckLogsCollected() bool
- func (v *FlagVars) CheckMetricsCollected() bool
- func (v *FlagVars) NetworkCmd() (NetworkCmd, error)
- func (v *FlagVars) NetworkDir() string
- func (v *FlagVars) NetworkOwner() string
- func (v *FlagVars) NetworkShutdownDelay() time.Duration
- func (v *FlagVars) NodeCount() (int, error)
- func (v *FlagVars) NodeRuntimeConfig() (*tmpnet.NodeRuntimeConfig, error)
- func (v *FlagVars) RootNetworkDir() string
- func (v *FlagVars) StartLogsCollector() bool
- func (v *FlagVars) StartMetricsCollector() bool
- type GinkgoTestContext
- func (*GinkgoTestContext) By(text string, callback ...func())
- func (*GinkgoTestContext) Cleanup()
- func (tc *GinkgoTestContext) ContextWithTimeout(duration time.Duration) context.Context
- func (tc *GinkgoTestContext) DefaultContext() context.Context
- func (*GinkgoTestContext) DeferCleanup(cleanup func())
- func (*GinkgoTestContext) Errorf(format string, args ...interface{})
- func (*GinkgoTestContext) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, msg string)
- func (*GinkgoTestContext) FailNow()
- func (tc *GinkgoTestContext) Log() log.Logger
- func (tc *GinkgoTestContext) WithDefaultContext() common.Option
- type NetworkCmd
- type TestEnvironment
- func (te *TestEnvironment) GetNetwork() *tmpnet.Network
- func (te *TestEnvironment) GetNodeURIs() []tmpnet.NodeURI
- func (te *TestEnvironment) GetRandomNodeURI() tmpnet.NodeURI
- func (te *TestEnvironment) Marshal() []byte
- func (te *TestEnvironment) NewKeychain() *secp256k1fx.Keychain
- func (te *TestEnvironment) StartPrivateNetwork(network *tmpnet.Network)
Constants ¶
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" )
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 geth repo in an e2e job. UsesCChainLabel = "uses-c" )
Variables ¶
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 ¶
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 ¶
DescribeCChain annotates the tests for C-Chain.
func DescribePChain ¶
DescribePChain annotates the tests for P-Chain.
func DescribeXChain ¶
DescribeXChain annotates the tests for X-Chain.
func DescribeXChainSerial ¶
DescribeXChainSerial annotates serial tests for X-Chain.
func ExecuteAPITest ¶ added in v1.11.14
func ExecuteAPITest(apiTest APITestFunction)
ExecuteAPITest executes a test whose primary dependency is being able to access the API of one or more luxd nodes.
func GetLocalStakingAddress ¶
GetLocalStakingAddress retrieves the locally-accessible staking address of the provided node. When a node is a local process, this will be the staking address exposed by the node. For a node running remotely in kube, the staking address will be a local address whose port will be forwarded to the node's staking address through the kube API server.
func GetLocalURI ¶
func GetLocalURI(tc tests.TestContext, node *tmpnet.Node) string
GetLocalURI retrieves the locally-accessible URI of the provided node. When a node is running as a local process, this will be the URI exposed by the node. For a node running remotely in kube, the URI will be a local address whose port is forwarded to the node's URI through the kube API server.
func GetRepoRootPath ¶
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 ¶
GetWalletBalances retrieves the X-Chain and P-Chain balances of the provided wallet.
func InitSharedTestEnvironment ¶
func InitSharedTestEnvironment(tc tests.TestContext, envBytes []byte)
func NewEthClient ¶
Create a new eth client targeting the specified node URI.
func NewPChainFeeCalculatorFromContext ¶
func NewPChainFeeCalculatorFromContext(context *builder.Context) fee.Calculator
NewPChainFeeCalculatorFromContext returns either a static or dynamic fee calculator depending on the provided context.
func NewPrivateKey ¶
func NewPrivateKey(tc tests.TestContext) *secp256k1.PrivateKey
NewPrivateKey creates a new private key
func NewTestContext ¶
func NewTestContext() tests.TestContext
NewTestContext creates a new test context for ginkgo-based tests
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 NewWalletWithContext ¶ added in v1.20.2
func NewWalletWithContext(tc tests.TestContext, keychain *secp256k1fx.Keychain, nodeURI tmpnet.NodeURI) primary.Wallet
NewWallet with TestContext - overloaded version for tests
func OutputWalletBalances ¶
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 ¶
func StartNetwork ¶
func StartNetwork( tc tests.TestContext, network *tmpnet.Network, rootNetworkDir string, shutdownDelay time.Duration, networkCmd NetworkCmd, )
Start a temporary network with the provided node binary.
func SuggestGasPrice ¶
Determines the suggested gas price for the configured client that will maximize the chances of transaction acceptance.
func WaitForHealthy ¶
Wait for the given node to report healthy.
func WithSuggestedGasPrice ¶
Helper simplifying use via an option of a gas price appropriate for testing.
Types ¶
type APITestEnvironment ¶ added in v1.17.2
type APITestEnvironment struct {
Network *tmpnet.Network
Nodes []*tmpnet.Node
Keychain *secp256k1fx.Keychain
}
APITestEnvironment represents the test environment for API tests
var APIEnv *APITestEnvironment
APIEnv is the global test environment for API tests
func GetAPIEnv ¶ added in v1.17.2
func GetAPIEnv(tc tests.TestContext) *APITestEnvironment
GetAPIEnv returns the test environment for API tests
func (*APITestEnvironment) GetNetwork ¶ added in v1.17.2
func (e *APITestEnvironment) GetNetwork() *tmpnet.Network
GetNetwork returns the test network
func (*APITestEnvironment) GetRandomNodeURI ¶ added in v1.17.2
func (e *APITestEnvironment) GetRandomNodeURI() tmpnet.NodeURI
GetRandomNodeURI returns a random node URI from the network
func (*APITestEnvironment) NewKeychain ¶ added in v1.17.2
func (e *APITestEnvironment) NewKeychain() *secp256k1fx.Keychain
NewKeychain creates a new keychain for testing
type APITestFunction ¶ added in v1.11.14
Additional test requirements: node URIs, network configuration, test timeouts
type DefaultOption ¶
type DefaultOption func(*DefaultOptions)
func WithDefaultNodeCount ¶
func WithDefaultNodeCount(nodeCount int) DefaultOption
func WithDefaultOwner ¶
func WithDefaultOwner(owner string) DefaultOption
type DefaultOptions ¶
type DefaultOptions struct {
// contains filtered or unexported fields
}
func (*DefaultOptions) NodeCount ¶
func (d *DefaultOptions) NodeCount() int
func (*DefaultOptions) Owner ¶
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 ¶
func (*FlagVars) CheckLogsCollected ¶
func (*FlagVars) CheckMetricsCollected ¶
func (*FlagVars) NetworkCmd ¶
func (v *FlagVars) NetworkCmd() (NetworkCmd, error)
func (*FlagVars) NetworkDir ¶
func (*FlagVars) NetworkOwner ¶
func (*FlagVars) NetworkShutdownDelay ¶
func (*FlagVars) NodeRuntimeConfig ¶
func (v *FlagVars) NodeRuntimeConfig() (*tmpnet.NodeRuntimeConfig, error)
func (*FlagVars) RootNetworkDir ¶
func (*FlagVars) StartLogsCollector ¶
func (*FlagVars) StartMetricsCollector ¶
type GinkgoTestContext ¶
type GinkgoTestContext struct {
// contains filtered or unexported fields
}
func NewEventHandlerTestContext ¶
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 ¶
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 ¶
func (*GinkgoTestContext) By(text string, callback ...func())
func (*GinkgoTestContext) Cleanup ¶
func (*GinkgoTestContext) Cleanup()
func (*GinkgoTestContext) ContextWithTimeout ¶
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 ¶
func (tc *GinkgoTestContext) DefaultContext() context.Context
Helper simplifying use of a timed context configured with the default timeout.
func (*GinkgoTestContext) DeferCleanup ¶
func (*GinkgoTestContext) DeferCleanup(cleanup func())
func (*GinkgoTestContext) Errorf ¶
func (*GinkgoTestContext) Errorf(format string, args ...interface{})
func (*GinkgoTestContext) Eventually ¶
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 ¶
func (*GinkgoTestContext) FailNow()
func (*GinkgoTestContext) Log ¶
func (tc *GinkgoTestContext) Log() log.Logger
func (*GinkgoTestContext) WithDefaultContext ¶
func (tc *GinkgoTestContext) WithDefaultContext() common.Option
Helper simplifying use via an option of a timed context configured with the default timeout.
type NetworkCmd ¶
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 ¶
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) GetNodeURIs ¶
func (te *TestEnvironment) GetNodeURIs() []tmpnet.NodeURI
Retrieve URIs for validator nodes of the shared network. The URIs are only guaranteed to be accessible until the environment test context is torn down (usually the duration of execution of a single test).
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 ¶
func (te *TestEnvironment) StartPrivateNetwork(network *tmpnet.Network)
Create a new private network that is not shared with other tests.