tests

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: GPL-3.0, LGPL-3.0 Imports: 28 Imported by: 0

README

Developing with tmpnet

The load/ and warp/ paths contain end-to-end (e2e) tests that use the tmpnet fixture. By default both test suites use the tmpnet fixture to create a temporary network that exists for only the duration of their execution.

It is possible to create a temporary network that can be reused across test runs to minimize the setup cost involved:

# From the root of a clone of avalanchego, build the tmpnetctl cli
$ ./scripts/build_tmpnetctl.sh

# Start a new temporary network configured with subnet-evm's default plugin path
$ ./build/tmpnetctl start-network \
  --avalanche-path=./build/avalanchego
  --plugin-dir=$GOPATH/src/github.com/ava-labs/avalanchego/build/plugins

# From the root of a clone of subnet-evm, execute the warp test suite against the existing network
$ ginkgo -vv ./tests/warp -- --use-existing-network --network-dir=$HOME/.tmpnet/networks/latest

# To stop the temporary network when no longer needed, execute the following from the root of the clone of avalanchego
$ ./build/tmpnetctl stop-network --network-dir=$HOME/.tmpnet/networks/latest

The network started by tmpnetctl won't come with subnets configured, so the test suite will add them to the network the first time it runs. Subsequent test runs will be able to reuse those subnets without having to set them up.

Collection of logs and metrics

Logs and metrics can be optionally collected for tmpnet networks and viewed in grafana. The details of configuration and usage for subnet-evm mirror those of avalanchego and the same documentation applies.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Forks = map[string]*params.ChainConfig{
	"Frontier": {
		ChainID: big.NewInt(1),
	},
	"Homestead": {
		ChainID:        big.NewInt(1),
		HomesteadBlock: big.NewInt(0),
	},
	"EIP150": {
		ChainID:        big.NewInt(1),
		HomesteadBlock: big.NewInt(0),
		EIP150Block:    big.NewInt(0),
	},
	"EIP158": {
		ChainID:        big.NewInt(1),
		HomesteadBlock: big.NewInt(0),
		EIP150Block:    big.NewInt(0),
		EIP155Block:    big.NewInt(0),
		EIP158Block:    big.NewInt(0),
	},
	"Byzantium": {
		ChainID:        big.NewInt(1),
		HomesteadBlock: big.NewInt(0),
		EIP150Block:    big.NewInt(0),
		EIP155Block:    big.NewInt(0),
		EIP158Block:    big.NewInt(0),
		ByzantiumBlock: big.NewInt(0),
	},
	"Constantinople": {
		ChainID:             big.NewInt(1),
		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(10000000),
	},
	"ConstantinopleFix": {
		ChainID:             big.NewInt(1),
		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
	},
	"Istanbul": {
		ChainID:             big.NewInt(1),
		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
	},
	"MuirGlacier": {
		ChainID:             big.NewInt(1),
		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
	},
	"FrontierToHomesteadAt5": {
		ChainID:        big.NewInt(1),
		HomesteadBlock: big.NewInt(5),
	},
	"HomesteadToEIP150At5": {
		ChainID:        big.NewInt(1),
		HomesteadBlock: big.NewInt(0),
		EIP150Block:    big.NewInt(5),
	},
	"EIP158ToByzantiumAt5": {
		ChainID:        big.NewInt(1),
		HomesteadBlock: big.NewInt(0),
		EIP150Block:    big.NewInt(0),
		EIP155Block:    big.NewInt(0),
		EIP158Block:    big.NewInt(0),
		ByzantiumBlock: big.NewInt(5),
	},
	"ByzantiumToConstantinopleAt5": {
		ChainID:             big.NewInt(1),
		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(5),
	},
	"ByzantiumToConstantinopleFixAt5": {
		ChainID:             big.NewInt(1),
		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(5),
		PetersburgBlock:     big.NewInt(5),
	},
	"ConstantinopleFixToIstanbulAt5": {
		ChainID:             big.NewInt(1),
		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(5),
	},
	"Pre-SubnetEVM": {
		ChainID:             big.NewInt(1),
		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		MuirGlacierBlock:    big.NewInt(0),
	},
	"SubnetEVM": {
		ChainID:             big.NewInt(1),
		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		NetworkUpgrades: params.NetworkUpgrades{
			SubnetEVMTimestamp: utils.NewUint64(0),
		},
	},
	"Durango": {
		ChainID:             big.NewInt(1),
		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		NetworkUpgrades: params.NetworkUpgrades{
			SubnetEVMTimestamp: utils.NewUint64(0),
			DurangoTimestamp:   utils.NewUint64(0),
		},
	},
	"Cancun": {
		ChainID:             big.NewInt(1),
		HomesteadBlock:      big.NewInt(0),
		EIP150Block:         big.NewInt(0),
		EIP155Block:         big.NewInt(0),
		EIP158Block:         big.NewInt(0),
		ByzantiumBlock:      big.NewInt(0),
		ConstantinopleBlock: big.NewInt(0),
		PetersburgBlock:     big.NewInt(0),
		IstanbulBlock:       big.NewInt(0),
		CancunTime:          utils.NewUint64(0),
		NetworkUpgrades: params.NetworkUpgrades{
			SubnetEVMTimestamp: utils.NewUint64(0),
			DurangoTimestamp:   utils.NewUint64(0),
		},
	},
}

Forks table defines supported forks and their chain config.

Functions

func AvailableForks

func AvailableForks() []string

AvailableForks returns the set of defined fork names

func FromHex

func FromHex(s string) ([]byte, error)

FromHex returns the bytes represented by the hexadecimal string s. s may be prefixed with "0x". This is copy-pasted from bytes.go, which does not return the error

func GetChainConfig

func GetChainConfig(forkString string) (baseConfig *params.ChainConfig, eips []int, err error)

GetChainConfig takes a fork definition and returns a chain config. The fork definition can be - a plain forkname, e.g. `Byzantium`, - a fork basename, and a list of EIPs to enable; e.g. `Byzantium+1884+1283`.

func GetRepoRootPath added in v0.6.2

func GetRepoRootPath(suffix string) string

func MakePreState

func MakePreState(db ethdb.Database, accounts core.GenesisAlloc, snapshotter bool, scheme string) (*trie.Database, *snapshot.Tree, *state.StateDB)

Types

type RLPTest

type RLPTest struct {
	// If the value of In is "INVALID" or "VALID", the test
	// checks whether Out can be decoded into a value of
	// type interface{}.
	//
	// For other JSON values, In is treated as a driver for
	// calls to rlp.Stream. The test also verifies that encoding
	// In produces the bytes in Out.
	In interface{}

	// Out is a hex-encoded RLP value.
	Out string
}

RLPTest is the JSON structure of a single RLP test.

func (*RLPTest) Run

func (t *RLPTest) Run() error

Run executes the test.

type StateSubtest

type StateSubtest struct {
	Fork  string
	Index int
}

StateSubtest selects a specific configuration of a General State Test.

type StateTest

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

StateTest checks transaction processing without block context. See https://github.com/ethereum/EIPs/issues/176 for the test format specification.

func (*StateTest) Run added in v0.5.4

func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config, snapshotter bool, scheme string, postCheck func(err error, snaps *snapshot.Tree, state *state.StateDB)) (result error)

Run executes a specific subtest and verifies the post-state and logs

func (*StateTest) RunNoVerify added in v0.5.4

func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapshotter bool, scheme string) (*trie.Database, *snapshot.Tree, *state.StateDB, common.Hash, error)

RunNoVerify runs a specific subtest and returns the statedb and post-state root

func (*StateTest) Subtests

func (t *StateTest) Subtests() []StateSubtest

Subtests returns all valid subtests of the test.

func (*StateTest) UnmarshalJSON

func (t *StateTest) UnmarshalJSON(in []byte) error

type UnsupportedForkError

type UnsupportedForkError struct {
	Name string
}

UnsupportedForkError is returned when a test requests a fork that isn't implemented.

func (UnsupportedForkError) Error

func (e UnsupportedForkError) Error() string

Directories

Path Synopsis
precompile
solidity
Implements solidity tests.
Implements solidity tests.

Jump to

Keyboard shortcuts

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