utils

package
v0.166.3 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: MPL-2.0 Imports: 21 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoRemoteURL is returned when network id has no associated url.
	ErrNoRemoteURL = errors.New("network id requires a remote URL")

	// ErrTimeout is returned when test times out
	ErrTimeout = errors.New("timeout")

	// TestConfig defines the default config usable at package-level.
	TestConfig *testConfig

	// RootDir is the main application directory
	RootDir string

	// TestDataDir is data directory used for tests
	TestDataDir string

	// TestNetworkNames network ID to name mapping
	TestNetworkNames = map[int]string{
		params.MainNetworkID:        "Mainnet",
		params.StatusChainNetworkID: "StatusChain",
		params.GoerliNetworkID:      "Goerli",
	}
)

Functions

func CheckTestSkipForNetworks

func CheckTestSkipForNetworks(t *testing.T, networks ...int)

CheckTestSkipForNetworks checks if network for test is one of the prohibited ones and skips the test in this case.

func EnsureNodeSync

func EnsureNodeSync(ensureSync EnsureSync)

EnsureNodeSync waits until node synchronzation is done to continue with tests afterwards. Panics in case of an error or a timeout.

func Eventually added in v0.35.0

func Eventually(f func() error, timeout, period time.Duration) (err error)

Eventually will raise error if condition won't be met during the given timeout.

func GetAccount1PKFile

func GetAccount1PKFile() string

GetAccount1PKFile returns the filename for Account1 keystore based on the current network. This allows running the e2e tests on the private network w/o access to the ACCOUNT_PASSWORD env variable

func GetAccount2PKFile

func GetAccount2PKFile() string

GetAccount2PKFile returns the filename for Account2 keystore based on the current network. This allows running the e2e tests on the private network w/o access to the ACCOUNT_PASSWORD env variable

func GetHeadHash

func GetHeadHash() string

GetHeadHash returns the hash associated with a given network id.

func GetHeadHashFromNetworkID

func GetHeadHashFromNetworkID(id int) string

GetHeadHashFromNetworkID returns the hash associated with a given network id.

func GetNetworkID

func GetNetworkID() int

GetNetworkID returns appropriate network id for test based on default or provided -network flag.

func GetRemoteURL

func GetRemoteURL() (string, error)

GetRemoteURL returns the url associated with a given network id.

func GetRemoteURLFromNetworkID

func GetRemoteURLFromNetworkID(id int) (url string, err error)

GetRemoteURLFromNetworkID returns associated network url for giving network id.

func ImportTestAccount

func ImportTestAccount(keystoreDir, accountFile string) error

ImportTestAccount imports keystore from static resources, see "static/keys" folder

func Init added in v0.35.0

func Init()

func LoadFromFile

func LoadFromFile(filename string) string

LoadFromFile is useful for loading test data, from testdata/filename into a variable nolint: errcheck

func MakeTestNodeConfig

func MakeTestNodeConfig(networkID int) (*params.NodeConfig, error)

MakeTestNodeConfig defines a function to return a params.NodeConfig where specific network addresses are assigned based on provided network id.

func MakeTestNodeConfigWithDataDir added in v0.10.2

func MakeTestNodeConfigWithDataDir(name, dataDir string, networkID uint64) (*params.NodeConfig, error)

MakeTestNodeConfigWithDataDir defines a function to return a params.NodeConfig where specific network addresses are assigned based on provided network id, and assigns a given name and data dir.

func WaitClosed

func WaitClosed(c <-chan struct{}, d time.Duration) error

WaitClosed used to wait on a channel in tests

Types

type EnsureSync

type EnsureSync func(context.Context) error

EnsureSync waits until blockchain synchronization is complete and returns.

Jump to

Keyboard shortcuts

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