utils

package
v1.21.41 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: BSD-3-Clause Imports: 43 Imported by: 0

Documentation

Overview

Copyright (C) 2022-2025, Lux Industries Inc. All rights reserved. See the file LICENSE for licensing terms.

Index

Constants

View Source
const (

	// Test blockchain and node names
	BlockchainName    = "test-blockchain"
	TestLocalNodeName = "test-local-node"

	// LPM related constants
	LPMDir       = ".lpm"
	LPMPluginDir = "plugins"

	BaseTest         = "./test/index.ts"
	GreeterScript    = "./scripts/deploy.ts"
	GreeterCheck     = "./scripts/checkGreeting.ts"
	SoloEVMKey1      = "soloEVMVersion1"
	SoloEVMKey2      = "soloEVMVersion2"
	SoloLuxKey       = "soloLuxVersion"
	SoloLuxdKey      = "soloLuxdVersion"
	OnlyLuxKey       = "onlyLuxVersion"
	MultiLuxEVMKey   = "multiLuxEVMVersion"
	MultiLux1Key     = "multiLuxVersion1"
	MultiLux2Key     = "multiLuxVersion2"
	LatestEVM2LuxKey = "latestEVM2Lux"
	LatestLux2EVMKey = "latestLux2EVM"
	OnlyLuxValue     = "latest"

	EVMGenesisPath    = "tests/e2e/assets/test_evm_genesis.json"
	EVMGenesis2Path   = "tests/e2e/assets/test_evm_genesis_2.json"
	EVMGenesisPoaPath = "tests/e2e/assets/test_evm_genesis.json" // POA uses same genesis for now
	LocalKeyPath      = "tests/e2e/assets/local_test_key.pk"     // Test key for E2E tests (deprecated ewoq)
	// Deprecated: Use LocalKeyPath instead
	EwoqKeyPath             = LocalKeyPath
	EVMAllowFeeRecpPath     = "tests/e2e/assets/test_evm_allowFeeRecps_genesis.json"
	EVMGenesisBadPath       = "tests/e2e/assets/test_evm_genesis_bad.json"
	BootstrapValidatorPath  = "tests/e2e/assets/test_bootstrap_validator.json"
	BootstrapValidatorPath2 = "tests/e2e/assets/test_bootstrap_validator2.json"

	PluginDirExt = "plugins"

	// Parse types for ParsePublicDeployOutput
	SubnetIDParseType     = "subnetID"
	BlockchainIDParseType = "blockchainID"
)
View Source
const (
	// LatestEVM2LuxdKey represents the latest EVM to Luxd compatibility key
	LatestEVM2LuxdKey = "v0.14.0"

	// LatestLuxd2EVMKey represents the latest Luxd to EVM compatibility key
	LatestLuxd2EVMKey = "v1.12.0"

	// LocalTestEVMAddress is the EVM address for the local test key (used in E2E tests)
	// NOTE: Tests still use this fixed address for compatibility; production uses env vars
	LocalTestEVMAddress = "0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC"
	// Deprecated: Use LocalTestEVMAddress instead
	EwoqEVMAddress = LocalTestEVMAddress
)

Test key constants

Variables

This section is empty.

Functions

func AddSubnetIDToSidecar

func AddSubnetIDToSidecar(subnetName string, network models.Network, subnetID string) error

func AllPermissionlessValidatorExistsInSidecar

func AllPermissionlessValidatorExistsInSidecar(subnetName string, network string) (bool, error)

func BlockchainConfigExists added in v1.9.5

func BlockchainConfigExists(blockchainName string) (bool, error)

BlockchainConfigExists checks if a blockchain configuration exists

func ChainConfigExists

func ChainConfigExists(subnetName string) (bool, error)

func CheckAllNodesAreCurrentValidators

func CheckAllNodesAreCurrentValidators(subnetName string) (bool, error)

func CheckEVMExists

func CheckEVMExists(version string) bool

func CheckKeyEquality

func CheckKeyEquality(keyPath1, keyPath2 string) (bool, error)

func CheckLuxExists

func CheckLuxExists(version string) bool

func CheckSnapshotExists added in v1.9.5

func CheckSnapshotExists(snapshotName string) bool

CheckSnapshotExists checks if a snapshot with the given name exists

func CheckUpgradeIsDeployed

func CheckUpgradeIsDeployed(rpcEndpoint string, deployedUpgrades extras.UpgradeConfig) error

func CleanupLogs added in v1.9.5

func CleanupLogs(nodesInfo map[string]NodeInfo, blockchainID string)

CleanupLogs removes log files for a specific blockchain from all nodes

func CleanupTmpFile added in v1.9.5

func CleanupTmpFile(path string) error

CleanupTmpFile removes a temporary file if it exists

func CreateTmpDir added in v1.9.5

func CreateTmpDir(prefix string) (string, error)

CreateTmpDir creates a temporary directory with the given prefix

func CreateTmpFile added in v1.9.5

func CreateTmpFile(namePrefix string, content []byte) (string, error)

CreateTmpFile creates a temporary file with the given name prefix and content

func DeleteBins

func DeleteBins() error

func DeleteConfigs

func DeleteConfigs(subnetName string) error

func DeleteCustomBinary

func DeleteCustomBinary(vmName string)

func DeleteKey

func DeleteKey(keyName string) error

func DeleteLPMBin

func DeleteLPMBin(vmid string)

func DeleteSnapshot added in v1.9.5

func DeleteSnapshot(snapshotName string) error

DeleteSnapshot removes a snapshot with the given name

func DownloadCustomVMBin

func DownloadCustomVMBin(evmVersion string) (string, error)

Currently downloads evm, but that suffices to test the custom vm functionality

func ElasticChainConfigExists added in v1.21.41

func ElasticChainConfigExists(subnetName string) (bool, error)

func FundAddress added in v1.9.5

func FundAddress(addr ids.ShortID, amount uint64) error

FundAddress funds an address with LUX tokens from the local test key account

func FundLedgerAddress

func FundLedgerAddress(amount uint64) error

func GetAPILargeContext added in v1.9.5

func GetAPILargeContext() (context.Context, context.CancelFunc)

GetAPILargeContext returns a context with a larger timeout suitable for API calls

func GetApp added in v1.9.5

func GetApp() *application.Lux

GetApp returns a new application instance for testing

func GetBaseDir

func GetBaseDir() string

func GetBlockchainID added in v1.9.5

func GetBlockchainID(blockchainName string) (string, error)

GetBlockchainID returns the blockchain ID for a given blockchain name

func GetCurrentSupply

func GetCurrentSupply(subnetName string) error

func GetE2EHostInstanceID added in v1.9.5

func GetE2EHostInstanceID() (string, error)

GetE2EHostInstanceID returns the instance ID for E2E testing

func GetERC20TokenAddress added in v1.9.5

func GetERC20TokenAddress(output string) (string, error)

GetERC20TokenAddress extracts the ERC20 token contract address from deployment output

func GetEVMMainnetChainID added in v1.21.40

func GetEVMMainnetChainID(subnetName string) (uint, error)

GetEVMMainnetChainID retrieves the mainnet chain ID for a EVM

func GetFileHash

func GetFileHash(filename string) (string, error)

func GetKeyTransferFee added in v1.9.5

func GetKeyTransferFee(output string, chain string) (uint64, error)

GetKeyTransferFee extracts the transfer fee from the transfer command output

func GetLPMDir

func GetLPMDir() string

func GetLatestEVMVersion added in v1.21.40

func GetLatestEVMVersion() string

GetLatestEVMVersion returns the latest available EVM version

func GetLedgerAddress added in v1.9.5

func GetLedgerAddress(network models.Network, index uint32) (string, error)

GetLedgerAddress retrieves the address from a ledger device

func GetLocalClusterNodesInfo added in v1.9.5

func GetLocalClusterNodesInfo() (map[string]NodeInfo, error)

GetLocalClusterNodesInfo retrieves information about local cluster nodes

func GetLocalClusterUris added in v1.9.5

func GetLocalClusterUris() ([]string, error)

GetLocalClusterUris returns the URIs for all nodes in the local network

func GetLocalNetworkNodesInfo added in v1.9.5

func GetLocalNetworkNodesInfo() (map[string]NodeInfo, error)

GetLocalNetworkNodesInfo returns node information for all local network nodes

func GetNodeVMVersion

func GetNodeVMVersion(nodeURI string, vmid string) (string, error)

func GetNodesInfo

func GetNodesInfo() (map[string]NodeInfo, error)

func GetPluginBinaries

func GetPluginBinaries() ([]string, error)

func GetPreviousEVMVersion added in v1.21.40

func GetPreviousEVMVersion() string

GetPreviousEVMVersion returns a previous EVM version for testing

func GetSideCar added in v1.9.5

func GetSideCar(subnetName string) (models.Sidecar, error)

GetSideCar returns the sidecar configuration for a given subnet name

func GetSignatureAggregatorContext added in v1.9.5

func GetSignatureAggregatorContext() (context.Context, context.CancelFunc)

GetSignatureAggregatorContext returns a context with timeout suitable for signature aggregation

func GetSnapshotsDir added in v1.9.5

func GetSnapshotsDir() string

GetSnapshotsDir returns the directory where snapshots are stored

func GetSubnetValidators added in v1.9.5

func GetSubnetValidators(subnetID ids.ID) ([]string, error)

GetSubnetValidators returns the validators for a subnet

func GetTmpFilePath added in v1.9.5

func GetTmpFilePath(prefix string) (string, error)

GetTmpFilePath creates and returns a temporary file path with the given prefix

func GetTokenTransferrerAddresses added in v1.9.5

func GetTokenTransferrerAddresses(output string) (string, string, error)

GetTokenTransferrerAddresses extracts the home and remote transferrer addresses from deployment output

func GetValidators

func GetValidators(subnetName string) ([]string, error)

func GetVersionMapping

func GetVersionMapping(mapper VersionMapper) (map[string]string, error)

GetVersionMapping returns a map of specific VMs resp. Lux e2e context keys to the actual version which corresponds to that key. This allows the e2e test to know what version to download and run. Returns an error if there was a problem reading the URL compatibility json or some other issue.

func GetWhitelistedSubnetsFromConfigFile

func GetWhitelistedSubnetsFromConfigFile(configFile string) (string, error)

func IsCustomVM added in v1.9.5

func IsCustomVM(subnetName string) (bool, error)

IsCustomVM checks if a subnet is using a custom VM

func IsNodeInPendingValidator

func IsNodeInPendingValidator(subnetName string, nodeID string) (bool, error)

func KeyExists

func KeyExists(keyName string) (bool, error)

func LPMConfigExists

func LPMConfigExists(subnetName string) (bool, error)

func ParseAddrBalanceFromKeyListOutput added in v1.9.5

func ParseAddrBalanceFromKeyListOutput(output string, keyName string, chain string) (string, uint64, error)

ParseAddrBalanceFromKeyListOutput parses the balance for a specific key and chain from key list output

func ParseBlockchainIDFromOutput added in v1.9.5

func ParseBlockchainIDFromOutput(output string) (string, error)

ParseBlockchainIDFromOutput parses the blockchain ID from deployment output

func ParseGreeterAddress

func ParseGreeterAddress(output string) error

func ParsePublicDeployOutput

func ParsePublicDeployOutput(output string, parseType string) (string, error)

func ParseRPCsFromOutput

func ParseRPCsFromOutput(output string) ([]string, error)

func ParseWarpContractAddressesFromOutput added in v1.9.5

func ParseWarpContractAddressesFromOutput(subnetName string, output string) (string, string, error)

ParseWarpContractAddressesFromOutput parses the Warp Messenger and Registry contract addresses from deploy output

func PerNodeChainConfigExists

func PerNodeChainConfigExists(subnetName string) (bool, error)

func PermissionlessValidatorExistsInSidecar

func PermissionlessValidatorExistsInSidecar(subnetName string, nodeID string, network string) (bool, error)

func PrintStdErr

func PrintStdErr(err error)

func RemoveLPMRepo

func RemoveLPMRepo()

func RestartNodes added in v1.9.5

func RestartNodes() error

RestartNodes restarts all nodes in the local network

func RestartNodesWithWhitelistedChains added in v1.21.38

func RestartNodesWithWhitelistedChains(whitelistedChains string) error

func RunHardhatScript

func RunHardhatScript(script string) (string, string, error)

func RunHardhatTests

func RunHardhatTests(test string) error

func SetHardhatRPC

func SetHardhatRPC(rpc string) error

func StartLedgerSim added in v1.9.5

func StartLedgerSim(interactionCount int, seed string, verbose bool) (chan struct{}, chan struct{})

StartLedgerSim simulates ledger interaction for testing Returns two channels: interactionEndCh and ledgerSimEndCh

func SubnetConfigExists

func SubnetConfigExists(subnetName string) (bool, error)

func SubnetCustomVMExists

func SubnetCustomVMExists(subnetName string) (bool, error)

func SubnetLPMVMExists

func SubnetLPMVMExists(subnetName string) (bool, error)

func TestCommand added in v1.9.5

func TestCommand(cmd, subCmd string, args []string, globalFlags GlobalFlags, testFlags TestFlags) (string, error)

TestCommand executes a command with the given flags for testing

func WaitSubnetValidators

func WaitSubnetValidators(subnetIDStr string, nodeInfos map[string]NodeInfo) error

Types

type GlobalFlags added in v1.9.5

type GlobalFlags map[string]interface{}

GlobalFlags represents global command flags as a map for flexible flag passing

type NodeInfo

type NodeInfo struct {
	ID         string
	PluginDir  string
	ConfigFile string
	URI        string
	LogDir     string
}

type TestFlags added in v1.9.5

type TestFlags map[string]interface{}

TestFlags represents test-specific flags as a map for flexible flag passing

type VersionMapper

type VersionMapper interface {
	GetCompatURL(vmType models.VMType) string
	GetLuxURL() string
	GetApp() *application.Lux
	GetLatestLuxByProtoVersion(app *application.Lux, rpcVersion int, url string) (string, error)
	GetEligibleVersions(sortedVersions []string, repoName string, app *application.Lux) ([]string, error)
}

VersionMapper is an abstraction for retrieving version compatibility URLs allowing unit tests without requiring external http calls. The idea is to finally calculate which VM is compatible with which Lux, so that the e2e tests can always download and run the latest compatible versions, without having to manually update the e2e tests periodically.

func NewVersionMapper

func NewVersionMapper() VersionMapper

NewVersionMapper returns the default VersionMapper for e2e tests

Jump to

Keyboard shortcuts

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