Skip to content

Commit

Permalink
set tmpnet exports for CLI interface
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemadero committed Feb 18, 2025
1 parent 10e5ccb commit eee8e62
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions tests/fixture/tmpnet/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func (n *Network) Create(rootDir string) error {
n.Dir = canonicalDir

// Ensure the existence of the plugin directory or nodes won't be able to start.
pluginDir, err := n.getPluginDir()
pluginDir, err := n.GetPluginDir()
if err != nil {
return err
}
Expand Down Expand Up @@ -480,7 +480,7 @@ func (n *Network) Bootstrap(ctx context.Context, log logging.Logger) error {
func (n *Network) StartNode(ctx context.Context, log logging.Logger, node *Node) error {
// This check is duplicative for a network that is starting, but ensures
// that individual node start/restart won't fail due to missing binaries.
pluginDir, err := n.getPluginDir()
pluginDir, err := n.GetPluginDir()
if err != nil {
return err
}
Expand All @@ -494,7 +494,7 @@ func (n *Network) StartNode(ctx context.Context, log logging.Logger, node *Node)
return err
}

bootstrapIPs, bootstrapIDs, err := n.getBootstrapIPsAndIDs(node)
bootstrapIPs, bootstrapIDs, err := n.GetBootstrapIPsAndIDs(node)
if err != nil {
return err
}
Expand Down Expand Up @@ -612,7 +612,7 @@ func (n *Network) EnsureNodeConfig(node *Node) error {
}

if n.Genesis != nil {
defaultFlags[config.GenesisFileKey] = n.getGenesisPath()
defaultFlags[config.GenesisFileKey] = n.GetGenesisPath()
}

// Only set the subnet dir if it exists or the node won't start.
Expand Down Expand Up @@ -843,7 +843,7 @@ func (n *Network) GetNodeURIs() []NodeURI {

// Retrieves bootstrap IPs and IDs for all nodes except the skipped one (this supports
// collecting the bootstrap details for restarting a node).
func (n *Network) getBootstrapIPsAndIDs(skippedNode *Node) ([]string, []string, error) {
func (n *Network) GetBootstrapIPsAndIDs(skippedNode *Node) ([]string, []string, error) {
// Collect staking addresses of non-ephemeral nodes for use in bootstrapping a node
nodes, err := ReadNodes(n.Dir, false /* includeEphemeral */)
if err != nil {
Expand Down Expand Up @@ -882,7 +882,7 @@ func (n *Network) GetNetworkID() uint32 {
return n.NetworkID
}

func (n *Network) getPluginDir() (string, error) {
func (n *Network) GetPluginDir() (string, error) {
return n.DefaultFlags.GetStringVal(config.PluginDirKey)
}

Expand Down
6 changes: 3 additions & 3 deletions tests/fixture/tmpnet/network_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ func (n *Network) writeNodes() error {
return nil
}

func (n *Network) getGenesisPath() string {
func (n *Network) GetGenesisPath() string {
return filepath.Join(n.Dir, "genesis.json")
}

func (n *Network) readGenesis() error {
bytes, err := os.ReadFile(n.getGenesisPath())
bytes, err := os.ReadFile(n.GetGenesisPath())
if err != nil {
return fmt.Errorf("failed to read genesis: %w", err)
}
Expand All @@ -103,7 +103,7 @@ func (n *Network) writeGenesis() error {
if err != nil {
return fmt.Errorf("failed to marshal genesis: %w", err)
}
if err := os.WriteFile(n.getGenesisPath(), bytes, perms.ReadWrite); err != nil {
if err := os.WriteFile(n.GetGenesisPath(), bytes, perms.ReadWrite); err != nil {
return fmt.Errorf("failed to write genesis: %w", err)
}
return nil
Expand Down
6 changes: 3 additions & 3 deletions tests/fixture/tmpnet/node_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import (
// The Node type is defined in this file node_config.go
// (reading/writing configuration) and node.go (orchestration).

func (n *Node) getFlagsPath() string {
func (n *Node) GetFlagsPath() string {
return filepath.Join(n.GetDataDir(), "flags.json")
}

func (n *Node) readFlags() error {
bytes, err := os.ReadFile(n.getFlagsPath())
bytes, err := os.ReadFile(n.GetFlagsPath())
if err != nil {
return fmt.Errorf("failed to read node flags: %w", err)
}
Expand All @@ -39,7 +39,7 @@ func (n *Node) writeFlags() error {
if err != nil {
return fmt.Errorf("failed to marshal node flags: %w", err)
}
if err := os.WriteFile(n.getFlagsPath(), bytes, perms.ReadWrite); err != nil {
if err := os.WriteFile(n.GetFlagsPath(), bytes, perms.ReadWrite); err != nil {
return fmt.Errorf("failed to write node flags: %w", err)
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion tests/fixture/tmpnet/node_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (p *NodeProcess) Start(log logging.Logger) error {
}

// All arguments are provided in the flags file
cmd := exec.Command(p.node.RuntimeConfig.AvalancheGoPath, "--config-file", p.node.getFlagsPath()) // #nosec G204
cmd := exec.Command(p.node.RuntimeConfig.AvalancheGoPath, "--config-file", p.node.GetFlagsPath()) // #nosec G204
// Ensure process is detached from the parent process so that an error in the parent will not affect the child
configureDetachedProcess(cmd)

Expand Down

0 comments on commit eee8e62

Please sign in to comment.