utils

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2018 License: MPL-2.0 Imports: 21 Imported by: 0

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.RopstenNetworkID:     "Ropsten",
		params.RinkebyNetworkID:     "Rinkeby",
		params.StatusChainNetworkID: "StatusChain",
	}
)

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 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 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