testnet

package
v1.10.9-rc.5 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: BSD-3-Clause Imports: 20 Imported by: 0

README

Test Network Fixture

This package contains configuration and interfaces that are independent of a given orchestration mechanism (e.g. local). The intent is to enable tests to be written against the interfaces defined in this package and for implementation-specific details of test network orchestration to be limited to test setup and teardown.

Documentation

Index

Constants

View Source
const (
	DefaultNodeCount      = 5
	DefaultFundedKeyCount = 50
)

Variables

This section is empty.

Functions

func DefaultJSONMarshal

func DefaultJSONMarshal(v interface{}) ([]byte, error)

Marshal to json with default prefix and indent.

func NewTestGenesis

func NewTestGenesis(
	networkID uint32,
	xChainBalances []AddrAndBalance,
	validatorIDs []ids.NodeID,
) (*genesis.UnparsedConfig, error)

Create a genesis struct valid for bootstrapping a test network. Note that many of the genesis fields (e.g. reward addresses) are randomly generated or hard-coded.

Types

type AddrAndBalance

type AddrAndBalance struct {
	Addr    ids.ShortID
	Balance uint64
}

type FlagsMap

type FlagsMap map[string]interface{}

Defines a mapping of flag keys to values intended to be supplied to an invocation of an AvalancheGo node.

func ReadFlagsMap

func ReadFlagsMap(path string, description string) (*FlagsMap, error)

Utility function simplifying construction of a FlagsMap from a file.

func (FlagsMap) GetStringVal

func (f FlagsMap) GetStringVal(key string) (string, error)

GetStringVal simplifies retrieving a map value as a string.

func (FlagsMap) SetDefaults

func (f FlagsMap) SetDefaults(defaults FlagsMap)

SetDefaults ensures the effectiveness of flag overrides by only setting values supplied in the defaults map that are not already explicitly set.

func (FlagsMap) Write

func (f FlagsMap) Write(path string, description string) error

Write simplifies writing a FlagsMap to the provided path. The description is used in error messages.

type Network

type Network interface {
	GetConfig() NetworkConfig
	GetNodes() []Node
}

Defines network capabilities supportable regardless of how a network is orchestrated.

type NetworkConfig

type NetworkConfig struct {
	Genesis      *genesis.UnparsedConfig
	CChainConfig FlagsMap
	DefaultFlags FlagsMap
	FundedKeys   []*secp256k1.PrivateKey
}

NetworkConfig defines configuration shared or common to all nodes in a given network.

func (*NetworkConfig) EnsureGenesis

func (c *NetworkConfig) EnsureGenesis(networkID uint32, validatorIDs []ids.NodeID) error

Ensure genesis is generated if not already present.

type Node

type Node interface {
	GetID() ids.NodeID
	GetConfig() NodeConfig
	GetProcessContext() node.NodeProcessContext
}

Defines node capabilities supportable regardless of how a network is orchestrated.

type NodeConfig

type NodeConfig struct {
	NodeID ids.NodeID
	Flags  FlagsMap
}

NodeConfig defines configuration for an AvalancheGo node.

func NewNodeConfig

func NewNodeConfig() *NodeConfig

func (*NodeConfig) EnsureBLSSigningKey

func (nc *NodeConfig) EnsureBLSSigningKey() error

Ensures a BLS signing key is generated if not already present.

func (*NodeConfig) EnsureKeys

func (nc *NodeConfig) EnsureKeys() error

Ensures staking and signing keys are generated if not already present and that the node ID (derived from the staking keypair) is set.

func (*NodeConfig) EnsureNodeID

func (nc *NodeConfig) EnsureNodeID() error

Attempt to derive the node ID from the node configuration.

func (*NodeConfig) EnsureStakingKeypair

func (nc *NodeConfig) EnsureStakingKeypair() error

Ensures a staking keypair is generated if not already present.

func (*NodeConfig) SetNetworkingConfigDefaults

func (nc *NodeConfig) SetNetworkingConfigDefaults(
	httpPort uint16,
	stakingPort uint16,
	bootstrapIDs []string,
	bootstrapIPs []string,
)

Convenience method for setting networking flags.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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