From 590046d44a7bf54e12ac3fa2bc63183d8cf18048 Mon Sep 17 00:00:00 2001 From: forcodedancing Date: Mon, 14 Aug 2023 14:03:32 +0800 Subject: [PATCH] fix some review comments --- x/sp/keeper/msg_server.go | 4 ++-- x/sp/keeper/msg_server_test.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/x/sp/keeper/msg_server.go b/x/sp/keeper/msg_server.go index d8bf58637..d41fed6b5 100644 --- a/x/sp/keeper/msg_server.go +++ b/x/sp/keeper/msg_server.go @@ -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) } diff --git a/x/sp/keeper/msg_server_test.go b/x/sp/keeper/msg_server_test.go index 30ca1666c..6515000f0 100644 --- a/x/sp/keeper/msg_server_test.go +++ b/x/sp/keeper/msg_server_test.go @@ -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 }