From ef631cb701f6b130ac95f8add84256623121974c Mon Sep 17 00:00:00 2001 From: Felipe Madero Date: Tue, 28 Jan 2025 17:31:05 -0300 Subject: [PATCH] nit --- pkg/localnet/track.go | 42 ++++++++++++++++++------------------ tests/e2e/commands/subnet.go | 6 +----- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/pkg/localnet/track.go b/pkg/localnet/track.go index 03c44bb9e..7fe08112a 100644 --- a/pkg/localnet/track.go +++ b/pkg/localnet/track.go @@ -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 @@ -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, @@ -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 @@ -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 { @@ -121,7 +126,6 @@ func TmpNetTrackSubnet( if err := TmpNetInstallVM(networkDir, vmBinaryPath, vmID); err != nil { return err } - // Configs if blockchainConfig != nil { if err := TmpNetSetBlockchainConfig( @@ -151,7 +155,6 @@ func TmpNetTrackSubnet( return err } } - // Add subnet to tracked and restart nodes if err := TmpNetRestartNodes( ctx, @@ -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 } diff --git a/tests/e2e/commands/subnet.go b/tests/e2e/commands/subnet.go index ef2551961..4699b8472 100644 --- a/tests/e2e/commands/subnet.go +++ b/tests/e2e/commands/subnet.go @@ -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 {