Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemadero committed Jan 28, 2025
1 parent 8890fc2 commit ef631cb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
42 changes: 21 additions & 21 deletions pkg/localnet/track.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ func LocalNetworkTrackSubnet(
blockchainName string,
) error {
networkModel := models.NewLocalNetwork()
networkDir, err := GetLocalNetworkDir(app)
sc, err := app.LoadSidecar(blockchainName)
if err != nil {
return err
}
if sc.Networks[networkModel.Name()].BlockchainID == ids.Empty {
return fmt.Errorf("blockchain %s has not been deployed to %s", blockchainName, networkModel.Name())
}
sovereign := sc.Sovereign
blockchainID := sc.Networks[networkModel.Name()].BlockchainID
subnetID := sc.Networks[networkModel.Name()].SubnetID
var (
blockchainConfig []byte
subnetConfig []byte
Expand All @@ -56,21 +62,24 @@ func LocalNetworkTrackSubnet(
if err != nil {
return err
}
sc, err := app.LoadSidecar(blockchainName)
wallet, err := GetLocalNetworkWallet(ctx, app, []ids.ID{subnetID})
if err != nil {
return err
}
subnetID := sc.Networks[networkModel.Name()].SubnetID
wallet, err := GetLocalNetworkWallet(ctx, app, []ids.ID{subnetID})
networkDir, err := GetLocalNetworkDir(app)
if err != nil {
return err
}
if err := TmpNetTrackSubnet(
ctx,
ux.Logger.GreenCheckmarkToUser,
app,
networkModel,
networkDir,
blockchainName,
sovereign,
blockchainID,
subnetID,
vmBinaryPath,
blockchainConfig,
subnetConfig,
Expand All @@ -79,6 +88,9 @@ func LocalNetworkTrackSubnet(
); err != nil {
return err
}
if err := TmpNetSetAlias(networkDir, blockchainID.String(), blockchainName, subnetID); err != nil {
return err
}
nodeURIs, err := GetTmpNetNodeURIs(networkDir)
if err != nil {
return err
Expand All @@ -92,27 +104,20 @@ func LocalNetworkTrackSubnet(

func TmpNetTrackSubnet(
ctx context.Context,
printFunc func(msg string, args ...interface{}),
app *application.Avalanche,
networkModel models.Network,
networkDir string,
blockchainName string,
sovereign bool,
blockchainID ids.ID,
subnetID ids.ID,
vmBinaryPath string,
blockchainConfig []byte,
subnetConfig []byte,
perNodeBlockchainConfig map[ids.NodeID][]byte,
wallet *primary.Wallet,
) error {
sc, err := app.LoadSidecar(blockchainName)
if err != nil {
return err
}
sovereign := sc.Sovereign
if sc.Networks[networkModel.Name()].BlockchainID == ids.Empty {
return fmt.Errorf("blockchain %s has not been deployed to %s", blockchainName, networkModel.Name())
}
blockchainID := sc.Networks[networkModel.Name()].BlockchainID
subnetID := sc.Networks[networkModel.Name()].SubnetID

// VM Binary setup
vmID, err := utils.VMID(blockchainName)
if err != nil {
Expand All @@ -121,7 +126,6 @@ func TmpNetTrackSubnet(
if err := TmpNetInstallVM(networkDir, vmBinaryPath, vmID); err != nil {
return err
}

// Configs
if blockchainConfig != nil {
if err := TmpNetSetBlockchainConfig(
Expand Down Expand Up @@ -151,7 +155,6 @@ func TmpNetTrackSubnet(
return err
}
}

// Add subnet to tracked and restart nodes
if err := TmpNetRestartNodes(
ctx,
Expand All @@ -176,10 +179,7 @@ func TmpNetTrackSubnet(
if err := WaitTmpNetBlockchainBootstrapped(ctx, networkDir, blockchainID.String(), subnetID); err != nil {
return err
}
if err := TmpNetSetAlias(networkDir, blockchainID.String(), blockchainName, subnetID); err != nil {
return err
}
ux.Logger.GreenCheckmarkToUser("%s successfully tracking %s", networkModel.Name(), blockchainName)
printFunc("%s successfully tracking %s", networkModel.Name(), blockchainName)
return nil
}

Expand Down
6 changes: 1 addition & 5 deletions tests/e2e/commands/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,7 @@ func DeploySubnetLocallyExpectErrorSOV(subnetName string) {
// Returns the deploy output
/* #nosec G204 */
func DeploySubnetLocallyWithViperConfNonSOV(subnetName string, confPath string) string {
mapper := utils.NewVersionMapper()
mapping, err := utils.GetVersionMapping(mapper)
gomega.Expect(err).Should(gomega.BeNil())

return DeploySubnetLocallyWithArgsNonSOV(subnetName, mapping[utils.OnlyAvagoKey], confPath)
return DeploySubnetLocallyWithArgsNonSOV(subnetName, "", confPath)
}

func DeploySubnetLocallyWithViperConfSOV(subnetName string, confPath string) string {
Expand Down

0 comments on commit ef631cb

Please sign in to comment.