Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(x/upgrade): Use ValidateBasic for Plan in ReadUpgradeInfoFromDisk (backport #18210) #18230

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading