e2e

package
v1.10.9 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: BSD-3-Clause Imports: 14 Imported by: 0

README

Lux e2e test suites

  • Works with fixture-managed temporary networks.
  • Compiles to a single binary with customizable configurations.

Running tests

go install -v github.com/onsi/ginkgo/v2/ginkgo@v2.0.0
ACK_GINKGO_RC=true ginkgo build ./tests/e2e
./tests/e2e/e2e.test --help

./tests/e2e/e2e.test \
--node-path=./build/node

See tests.e2e.sh for an example.

Filtering test execution with labels

In cases where a change can be verified against only a subset of tests, it is possible to filter the tests that will be executed by the declarative labels that have been applied to them. Available labels are defined as constants in describe.go with names of the form *Label. The following example runs only those tests that primarily target the X-Chain:

./tests/e2e/e2e.test \
  --node-path=./build/node \
  --ginkgo.label-filter=x

The ginkgo docs provide further detail on how to compose label queries.

Adding tests

Define any flags/configurations in e2e.go.

Create a new package to implement feature-specific tests, or add tests to an existing package. For example:

.
└── e2e
    ├── README.md
    ├── e2e.go
    ├── e2e_test.go
    └── x
        └── transfer.go
            └── virtuous.go

e2e.go defines common configuration for other test packages. x/transfer/virtuous.go defines X-Chain transfer tests, labeled with x, which can be selected by ./tests/e2e/e2e.test --ginkgo.label-filter "x".

Testing against an existing network

By default, a new temporary test network will be started before each test run and stopped at the end of the run. When developing e2e tests, it may be helpful to create a temporary network that can be used across multiple test runs. This can increase the speed of iteration by removing the requirement to start a new network for every invocation of the test under development.

To create an temporary network for use across test runs:

# From the root of the node repo

# Build the tmpnetctl binary
$ ./scripts/build_tmpnetctl.sh

# Start a new network
$ ./build/tmpnetctl start-network --node-path=/path/to/node
...
Started network 1000 @ /home/me/.tmpnet/networks/1000

Configure tmpnetctl and the test suite to target this network by default
with one of the following statements:
 - source /home/me/.tmpnet/networks/1000/network.env
 - export TMPNET_NETWORK_DIR=/home/me/.tmpnet/networks/1000
 - export TMPNET_NETWORK_DIR=/home/me/.tmpnet/networks/latest

# Start a new test run using the existing network
ginkgo -v ./tests/e2e -- \
    --node-path=/path/to/node \
    --ginkgo.focus-file=[name of file containing test] \
    --use-existing-network \
    --network-dir=/path/to/network

# It is also possible to set the LUXGO_PATH env var instead of supplying --node-path
# and to set TMPNET_NETWORK_DIR instead of supplying --network-dir.

See the tmpnet fixture README for more details.

Skipping bootstrap checks

By default many tests will attempt to bootstrap a new node with the post-test network state. While this is a valuable activity to perform in CI, it can add considerable latency to test development. To disable these bootstrap checks during development, set the E2E_SKIP_BOOTSTRAP_CHECKS env var to a non-empty value:

E2E_SKIP_BOOTSTRAP_CHECKS=1 ginkgo -v ./tests/e2e ...

Documentation

Overview

e2e implements the e2e tests.

Index

Constants

View Source
const (
	Unknown ClusterType = iota
	StandAlone
	PreExisting

	// Enough for primary.NewWallet to fetch initial UTXOs.
	DefaultWalletCreationTimeout = 5 * time.Second

	// Defines default tx confirmation timeout.
	// Enough for test/custom networks.
	DefaultConfirmTxTimeout = 20 * time.Second

	DefaultTimeout = 2 * time.Minute
)

Variables

View Source
var (
	Env = &TestEnvironment{
		testEnvironmentConfig: &testEnvironmentConfig{
			clusterType: Unknown,
		},
	}
)

Env is the global struct containing all we need to test

Functions

func DescribePChain

func DescribePChain(text string, body func()) bool

DescribePChain annotates the tests for P-Chain. Can run with any type of cluster (e.g., local, testnet, mainnet).

func DescribeXChain

func DescribeXChain(text string, body func()) bool

DescribeXChain annotates the tests for X-Chain. Can run with any type of cluster (e.g., local, testnet, mainnet).

Types

type ClusterType

type ClusterType byte

type TestEnvironment

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

func (*TestEnvironment) ConfigCluster

func (te *TestEnvironment) ConfigCluster(
	logLevel string,
	networkRunnerGRPCEp string,
	luxGoExecPath string,
	luxGoLogLevel string,
	uris string,
	testKeysFile string,
) error

should be called only once must be called before StartCluster Note that either networkRunnerGRPCEp or uris must be specified

func (*TestEnvironment) GetRunnerClient

func (te *TestEnvironment) GetRunnerClient() (cli runner_sdk.Client)

func (*TestEnvironment) GetRunnerGRPCEndpoint

func (te *TestEnvironment) GetRunnerGRPCEndpoint() (ep string)

func (*TestEnvironment) GetTestKeys

func (te *TestEnvironment) GetTestKeys() ([]*secp256k1.PrivateKey, []ids.ShortID, *secp256k1fx.Keychain)

func (*TestEnvironment) GetURIs

func (te *TestEnvironment) GetURIs() []string

func (*TestEnvironment) LoadKeys

func (te *TestEnvironment) LoadKeys() error

func (*TestEnvironment) RestoreInitialState

func (te *TestEnvironment) RestoreInitialState(switchOffNetworkFirst bool) error

func (*TestEnvironment) ShutdownCluster

func (te *TestEnvironment) ShutdownCluster() error

func (*TestEnvironment) SnapInitialState

func (te *TestEnvironment) SnapInitialState() error

func (*TestEnvironment) StartCluster

func (te *TestEnvironment) StartCluster() error

Directories

Path Synopsis
Implements tests for the banff network upgrade.
Implements tests for the banff network upgrade.
c
AUTOMATICALLY GENERATED.
AUTOMATICALLY GENERATED.
p
Implements ping tests, requires network-runner cluster.
Implements ping tests, requires network-runner cluster.
Implements static handlers tests for avm and platformvm
Implements static handlers tests for avm and platformvm
x
transfer
Implements X-chain transfer tests.
Implements X-chain transfer tests.
whitelist-vtx
Implements X-Chain whitelist vtx (stop vertex) tests.
Implements X-Chain whitelist vtx (stop vertex) tests.

Jump to

Keyboard shortcuts

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