Skip to content

Commit

Permalink
chore(x/upgrade): Use ValidateBasic for Plan in ReadUpgradeInfoFromDi…
Browse files Browse the repository at this point in the history
…sk (backport #18210) (#18230)

Co-authored-by: Facundo Medica <[email protected]>
Co-authored-by: Julien Robert <[email protected]>
  • Loading branch information
3 people authored Oct 24, 2023
1 parent 269a245 commit 98a8bfe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions x/upgrade/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,10 @@ func (k Keeper) ReadUpgradeInfoFromDisk() (types.Plan, error) {
return upgradeInfo, err
}

if err := upgradeInfo.ValidateBasic(); err != nil {
return upgradeInfo, err
}

return upgradeInfo, nil
}

Expand Down
6 changes: 6 additions & 0 deletions x/upgrade/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ func (s *KeeperTestSuite) TestReadUpgradeInfoFromDisk() {
s.Require().NoError(err)
expected.Height = 101
s.Require().Equal(expected, ui)

// create invalid upgrade plan (with empty name)
expected.Name = ""
s.Require().NoError(s.upgradeKeeper.DumpUpgradeInfoToDisk(101, expected))
_, err = s.upgradeKeeper.ReadUpgradeInfoFromDisk()
s.Require().ErrorContains(err, "name cannot be empty: invalid request")
}

func (s *KeeperTestSuite) TestScheduleUpgrade() {
Expand Down

0 comments on commit 98a8bfe

Please sign in to comment.