Skip to content

Commit

Permalink
fix some review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
forcodedancing committed Aug 14, 2023
1 parent 33f046a commit 590046d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions x/sp/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,9 @@ func (k msgServer) UpdateSpStoragePrice(goCtx context.Context, msg *types.MsgUpd
}

func IsLastDaysOfTheMonth(now time.Time, days int) bool {
now = now.UTC()
year, month, _ := now.Date()
location := now.Location()
nextMonth := time.Date(year, month+1, 1, 0, 0, 0, 0, location)
nextMonth := time.Date(year, month+1, 1, 0, 0, 0, 0, time.FixedZone("UTC", 0))
daysBack := nextMonth.AddDate(0, 0, -1*days)
return now.After(daysBack)
}
Expand Down
8 changes: 4 additions & 4 deletions x/sp/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ func (s *KeeperTestSuite) TestMsgCreateStorageProvider() {
}

func (s *KeeperTestSuite) TestIsLastDaysOfTheMonth() {
s.Require().True(!keeper.IsLastDaysOfTheMonth(time.Unix(1693242061, 0).UTC(), 2)) // 2023-08-28 UTC
s.Require().True(!keeper.IsLastDaysOfTheMonth(time.Unix(1693328461, 0).UTC(), 2)) // 2023-08-29 UTC
s.Require().True(keeper.IsLastDaysOfTheMonth(time.Unix(1693414861, 0).UTC(), 2)) // 2023-08-30 UTC
s.Require().True(!keeper.IsLastDaysOfTheMonth(time.Unix(1693587661, 0).UTC(), 2)) // 2023-09-01 UTC
s.Require().True(!keeper.IsLastDaysOfTheMonth(time.Unix(1693242061, 0), 2)) // 2023-08-28 UTC
s.Require().True(!keeper.IsLastDaysOfTheMonth(time.Unix(1693328461, 0), 2)) // 2023-08-29 UTC
s.Require().True(keeper.IsLastDaysOfTheMonth(time.Unix(1693414861, 0), 2)) // 2023-08-30 UTC
s.Require().True(!keeper.IsLastDaysOfTheMonth(time.Unix(1693587661, 0), 2)) // 2023-09-01 UTC
}

0 comments on commit 590046d

Please sign in to comment.