Skip to content

Commit

Permalink
fix test; better naming
Browse files Browse the repository at this point in the history
  • Loading branch information
psiphi5 committed Sep 20, 2024
1 parent 2fb3b68 commit 66c7be2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions tools/cosmovisor/args_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ var newConfig = func(
CustomPreUpgrade: customPreUpgrade,
DisableRecase: disableRecase,
ShutdownGrace: time.Duration(shutdownGrace),
CometBftRpcEndpoint: "http://localhost:26657",
}
}

Expand Down
10 changes: 5 additions & 5 deletions tools/cosmovisor/cmd/cosmovisor/add_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func NewAddUpgradeCmd() *cobra.Command {
return addUpgrade
}

// AddUpgrade adds upgrade info to manifest
func AddUpgrade(cfg *cosmovisor.Config, force bool, upgradeHeight int64, upgradeName, executablePath, upgradeInfoPath string) error {
// addUpgrade adds upgrade info to manifest
func addUpgrade(cfg *cosmovisor.Config, force bool, upgradeHeight int64, upgradeName, executablePath, upgradeInfoPath string) error {
logger := cfg.Logger(os.Stdout)

if !cfg.DisableRecase {
Expand Down Expand Up @@ -86,7 +86,7 @@ func AddUpgrade(cfg *cosmovisor.Config, force bool, upgradeHeight int64, upgrade
}

// GetConfig returns a Config using passed-in flag
func GetConfig(cmd *cobra.Command) (*cosmovisor.Config, error) {
func getConfigFromCmd(cmd *cobra.Command) (*cosmovisor.Config, error) {
configPath, err := cmd.Flags().GetString(cosmovisor.FlagCosmovisorConfig)
if err != nil {
return nil, fmt.Errorf("failed to get config flag: %w", err)
Expand All @@ -101,7 +101,7 @@ func GetConfig(cmd *cobra.Command) (*cosmovisor.Config, error) {

// AddUpgradeCmd parses input flags and adds upgrade info to manifest
func AddUpgradeCmd(cmd *cobra.Command, args []string) error {
cfg, err := GetConfig(cmd)
cfg, err := getConfigFromCmd(cmd)
if err != nil {
return err
}
Expand All @@ -118,7 +118,7 @@ func AddUpgradeCmd(cmd *cobra.Command, args []string) error {
return fmt.Errorf("failed to get upgrade-height flag: %w", err)
}

return AddUpgrade(cfg, force, upgradeHeight, upgradeName, executablePath, cfg.UpgradeInfoFilePath())
return addUpgrade(cfg, force, upgradeHeight, upgradeName, executablePath, cfg.UpgradeInfoFilePath())
}

// saveOrAbort saves data to path or aborts if file exists and force is false
Expand Down
4 changes: 2 additions & 2 deletions tools/cosmovisor/cmd/cosmovisor/batch_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewBatchAddUpgradeCmd() *cobra.Command {
// AddBatchUpgrade takes in multiple specified upgrades and creates a single
// batch upgrade file out of them
func AddBatchUpgrade(cmd *cobra.Command, args []string) error {
cfg, err := GetConfig(cmd)
cfg, err := getConfigFromCmd(cmd)
if err != nil {
return err
}
Expand All @@ -42,7 +42,7 @@ func AddBatchUpgrade(cmd *cobra.Command, args []string) error {
}
upgradeInfoPath := filepath.Join(cfg.UpgradeInfoFilePath(), upgradeName)
upgradeInfoPaths = append(upgradeInfoPaths, upgradeInfoPath)
if err := AddUpgrade(cfg, true, upgradeHeight, upgradeName, upgradePath, upgradeInfoPath); err != nil {
if err := addUpgrade(cfg, true, upgradeHeight, upgradeName, upgradePath, upgradeInfoPath); err != nil {
return err
}
}
Expand Down
6 changes: 3 additions & 3 deletions tools/cosmovisor/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ func loadBatchUpgradeFile(cfg *Config) ([]upgradetypes.Plan, error) {
return uInfos, nil
}

// BatchWatcher starts a watcher loop that swaps upgrade manifests at the correct
// BatchUpgradeWatcher starts a watcher loop that swaps upgrade manifests at the correct
// height, given the batch upgrade file. It watches the current state of the chain
// via the websocket API.
func BatchWatcher(ctx context.Context, cfg *Config, logger log.Logger) {
func BatchUpgradeWatcher(ctx context.Context, cfg *Config, logger log.Logger) {
// load batch file in memory
uInfos, err := loadBatchUpgradeFile(cfg)
if err != nil {
Expand Down Expand Up @@ -211,7 +211,7 @@ func (l Launcher) Run(args []string, stdin io.Reader, stdout, stderr io.Writer)
}
}()

go BatchWatcher(ctx, l.cfg, l.logger)
go BatchUpgradeWatcher(ctx, l.cfg, l.logger)

Check notice

Code scanning / CodeQL

Spawning a Go routine Note

Spawning a Go routine may be a possible source of non-determinism

if needsUpdate, err := l.WaitForUpgradeOrExit(cmd); err != nil || !needsUpdate {
return false, err
Expand Down

0 comments on commit 66c7be2

Please sign in to comment.