Documentation ¶
Index ¶
- Constants
- func FindNextNetworkID(rootDir string) (uint32, string, error)
- func GetDefaultRootDir() (string, error)
- func LocalCChainConfig() testnet.FlagsMap
- func LocalFlags() testnet.FlagsMap
- func StopNetwork(dir string) error
- type LocalConfig
- type LocalNetwork
- func (ln *LocalNetwork) AddEphemeralNode(w io.Writer, flags testnet.FlagsMap) (testnet.Node, error)
- func (ln *LocalNetwork) AddLocalNode(w io.Writer, node *LocalNode, isEphemeral bool) (*LocalNode, error)
- func (ln *LocalNetwork) EnvFileContents() string
- func (ln *LocalNetwork) EnvFilePath() string
- func (ln *LocalNetwork) GetBootstrapIPsAndIDs() ([]string, []string, error)
- func (ln *LocalNetwork) GetCChainConfigPath() string
- func (ln *LocalNetwork) GetChainConfigDir() string
- func (ln *LocalNetwork) GetConfig() testnet.NetworkConfig
- func (ln *LocalNetwork) GetDefaultsPath() string
- func (ln *LocalNetwork) GetGenesisPath() string
- func (ln *LocalNetwork) GetNodes() []testnet.Node
- func (ln *LocalNetwork) GetURIs() []testnet.NodeURI
- func (ln *LocalNetwork) PopulateLocalNetworkConfig(networkID uint32, nodeCount int, keyCount int) error
- func (ln *LocalNetwork) PopulateNodeConfig(node *LocalNode, nodeParentDir string) error
- func (ln *LocalNetwork) ReadAll() error
- func (ln *LocalNetwork) ReadCChainConfig() error
- func (ln *LocalNetwork) ReadConfig() error
- func (ln *LocalNetwork) ReadDefaults() error
- func (ln *LocalNetwork) ReadGenesis() error
- func (ln *LocalNetwork) ReadNodes() error
- func (ln *LocalNetwork) Start(w io.Writer) error
- func (ln *LocalNetwork) Stop() error
- func (ln *LocalNetwork) WaitForHealthy(ctx context.Context, w io.Writer) error
- func (ln *LocalNetwork) WriteAll() error
- func (ln *LocalNetwork) WriteCChainConfig() error
- func (ln *LocalNetwork) WriteDefaults() error
- func (ln *LocalNetwork) WriteEnvFile() error
- func (ln *LocalNetwork) WriteGenesis() error
- func (ln *LocalNetwork) WriteNodes() error
- type LocalNode
- func (n *LocalNode) GetConfig() testnet.NodeConfig
- func (n *LocalNode) GetConfigPath() string
- func (n *LocalNode) GetDataDir() string
- func (n *LocalNode) GetID() ids.NodeID
- func (n *LocalNode) GetProcess() (*os.Process, error)
- func (n *LocalNode) GetProcessContext() node.NodeProcessContext
- func (n *LocalNode) GetProcessContextPath() string
- func (n *LocalNode) IsHealthy(ctx context.Context) (bool, error)
- func (n *LocalNode) ReadAll() error
- func (n *LocalNode) ReadConfig() error
- func (n *LocalNode) ReadProcessContext() error
- func (n *LocalNode) Start(w io.Writer, defaultExecPath string) error
- func (n *LocalNode) Stop() error
- func (n *LocalNode) WaitForProcessContext(ctx context.Context) error
- func (n *LocalNode) WriteConfig() error
Constants ¶
const ( // Constants defining the names of shell variables whose value can // configure local network orchestration. MetalGoPathEnvName = "METALGO_PATH" NetworkDirEnvName = "TESTNETCTL_NETWORK_DIR" RootDirEnvName = "TESTNETCTL_ROOT_DIR" DefaultNetworkStartTimeout = 2 * time.Minute DefaultNodeInitTimeout = 10 * time.Second DefaultNodeStopTimeout = 5 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func FindNextNetworkID ¶
Find the next available network ID by attempting to create a directory numbered from 1000 until creation succeeds. Returns the network id and the full path of the created directory.
func GetDefaultRootDir ¶
Default root dir for storing networks and their configuration.
func LocalCChainConfig ¶
C-Chain config for local testing.
func StopNetwork ¶
Stop the nodes of the network configured in the provided directory.
Types ¶
type LocalConfig ¶
type LocalConfig struct { // Path to avalanchego binary ExecPath string }
Defines local-specific node configuration. Supports setting default and node-specific values.
TODO(marun) Support persisting this configuration per-node when node restart is implemented. Currently it can be supplied for node start but won't survive restart.
type LocalNetwork ¶
type LocalNetwork struct { testnet.NetworkConfig LocalConfig // Nodes with local configuration Nodes []*LocalNode // Path where network configuration will be stored Dir string }
Defines the configuration required for a local network (i.e. one composed of local processes).
func ReadNetwork ¶
func ReadNetwork(dir string) (*LocalNetwork, error)
Read a network from the provided directory.
func StartNetwork ¶
func StartNetwork( ctx context.Context, w io.Writer, rootDir string, network *LocalNetwork, nodeCount int, keyCount int, ) (*LocalNetwork, error)
Starts a new network stored under the provided root dir. Required configuration will be defaulted if not provided.
func (*LocalNetwork) AddEphemeralNode ¶ added in v1.10.10
Adds a backend-agnostic ephemeral node to the network
func (*LocalNetwork) AddLocalNode ¶ added in v1.10.10
func (*LocalNetwork) EnvFileContents ¶
func (ln *LocalNetwork) EnvFileContents() string
func (*LocalNetwork) EnvFilePath ¶
func (ln *LocalNetwork) EnvFilePath() string
func (*LocalNetwork) GetBootstrapIPsAndIDs ¶ added in v1.10.13
func (ln *LocalNetwork) GetBootstrapIPsAndIDs() ([]string, []string, error)
func (*LocalNetwork) GetCChainConfigPath ¶
func (ln *LocalNetwork) GetCChainConfigPath() string
func (*LocalNetwork) GetChainConfigDir ¶
func (ln *LocalNetwork) GetChainConfigDir() string
func (*LocalNetwork) GetConfig ¶
func (ln *LocalNetwork) GetConfig() testnet.NetworkConfig
Returns the configuration of the network in backend-agnostic form.
func (*LocalNetwork) GetDefaultsPath ¶
func (ln *LocalNetwork) GetDefaultsPath() string
func (*LocalNetwork) GetGenesisPath ¶
func (ln *LocalNetwork) GetGenesisPath() string
func (*LocalNetwork) GetNodes ¶
func (ln *LocalNetwork) GetNodes() []testnet.Node
Returns the nodes of the network in backend-agnostic form.
func (*LocalNetwork) GetURIs ¶
func (ln *LocalNetwork) GetURIs() []testnet.NodeURI
Retrieve API URIs for all running primary validator nodes. URIs for ephemeral nodes are not returned.
func (*LocalNetwork) PopulateLocalNetworkConfig ¶
func (ln *LocalNetwork) PopulateLocalNetworkConfig(networkID uint32, nodeCount int, keyCount int) error
Ensure the network has the configuration it needs to start.
func (*LocalNetwork) PopulateNodeConfig ¶
func (ln *LocalNetwork) PopulateNodeConfig(node *LocalNode, nodeParentDir string) error
Ensure the provided node has the configuration it needs to start. If the data dir is not set, it will be defaulted to [nodeParentDir]/[node ID]. Requires that the network has valid genesis data.
func (*LocalNetwork) ReadAll ¶
func (ln *LocalNetwork) ReadAll() error
Read network and node configuration from disk.
func (*LocalNetwork) ReadCChainConfig ¶
func (ln *LocalNetwork) ReadCChainConfig() error
func (*LocalNetwork) ReadConfig ¶
func (ln *LocalNetwork) ReadConfig() error
Read network configuration from disk.
func (*LocalNetwork) ReadDefaults ¶
func (ln *LocalNetwork) ReadDefaults() error
func (*LocalNetwork) ReadGenesis ¶
func (ln *LocalNetwork) ReadGenesis() error
func (*LocalNetwork) ReadNodes ¶
func (ln *LocalNetwork) ReadNodes() error
Read node configuration and process context from disk.
func (*LocalNetwork) Start ¶
func (ln *LocalNetwork) Start(w io.Writer) error
Starts a network for the first time
func (*LocalNetwork) WaitForHealthy ¶
Wait until all nodes in the network are healthy.
func (*LocalNetwork) WriteAll ¶
func (ln *LocalNetwork) WriteAll() error
Write network configuration to disk.
func (*LocalNetwork) WriteCChainConfig ¶
func (ln *LocalNetwork) WriteCChainConfig() error
func (*LocalNetwork) WriteDefaults ¶
func (ln *LocalNetwork) WriteDefaults() error
func (*LocalNetwork) WriteEnvFile ¶
func (ln *LocalNetwork) WriteEnvFile() error
Write an env file that sets the network dir env when sourced.
func (*LocalNetwork) WriteGenesis ¶
func (ln *LocalNetwork) WriteGenesis() error
func (*LocalNetwork) WriteNodes ¶
func (ln *LocalNetwork) WriteNodes() error
type LocalNode ¶
type LocalNode struct { testnet.NodeConfig LocalConfig node.NodeProcessContext }
Stores the configuration and process details of a node in a local network.
func NewLocalNode ¶
func ReadNode ¶
Attempt to read configuration and process details for a local node from the specified directory.
func (*LocalNode) GetConfig ¶
func (n *LocalNode) GetConfig() testnet.NodeConfig
Retrieve backend-agnostic node configuration.
func (*LocalNode) GetConfigPath ¶
func (*LocalNode) GetDataDir ¶
func (*LocalNode) GetID ¶
Retrieve the ID of the node. The returned value may be nil if the node configuration has not yet been populated or read.
func (*LocalNode) GetProcess ¶
Retrieve the node process if it is running. As part of determining process liveness, the node's process context will be refreshed if live or cleared if not running.
func (*LocalNode) GetProcessContext ¶
func (n *LocalNode) GetProcessContext() node.NodeProcessContext
Retrieve backend-agnostic process details.
func (*LocalNode) GetProcessContextPath ¶
func (*LocalNode) ReadConfig ¶
func (*LocalNode) ReadProcessContext ¶
func (*LocalNode) Stop ¶
Signals the node process to stop and waits for the node process to stop running.