From ed889024f5566505dc309e094bac440077af12cd Mon Sep 17 00:00:00 2001 From: Kitipong Sirirueangsakul Date: Sat, 30 Nov 2024 06:16:01 +0700 Subject: [PATCH] fix default timestamp for not_in_current_feeds --- x/feeds/keeper/grpc_query_test.go | 11 ++++++++--- x/feeds/keeper/keeper_price.go | 2 +- x/feeds/keeper/keeper_price_test.go | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/x/feeds/keeper/grpc_query_test.go b/x/feeds/keeper/grpc_query_test.go index cefb7c3d6..5a47e6b2c 100644 --- a/x/feeds/keeper/grpc_query_test.go +++ b/x/feeds/keeper/grpc_query_test.go @@ -69,7 +69,7 @@ func (suite *KeeperTestSuite) TestQueryPrice() { Status: types.PRICE_STATUS_NOT_IN_CURRENT_FEEDS, SignalID: "CS:ATOM-USD", Price: 0, - Timestamp: 0, + Timestamp: suite.ctx.BlockTime().Unix(), }, }, res) } @@ -120,7 +120,7 @@ func (suite *KeeperTestSuite) TestQueryPrices() { SignalID: "CS:NON-EXISTENT", Status: types.PRICE_STATUS_NOT_IN_CURRENT_FEEDS, Price: 0, - Timestamp: 0, + Timestamp: suite.ctx.BlockTime().Unix(), }, }, }, @@ -138,7 +138,12 @@ func (suite *KeeperTestSuite) TestQueryPrices() { signalIDs: []string{"CS:BAND-USD", "CS:NON-EXISTENT"}, expectedPrices: []types.Price{ prices[0], - {SignalID: "CS:NON-EXISTENT", Status: types.PRICE_STATUS_NOT_IN_CURRENT_FEEDS, Price: 0, Timestamp: 0}, + { + SignalID: "CS:NON-EXISTENT", + Status: types.PRICE_STATUS_NOT_IN_CURRENT_FEEDS, + Price: 0, + Timestamp: suite.ctx.BlockTime().Unix(), + }, }, }, { diff --git a/x/feeds/keeper/keeper_price.go b/x/feeds/keeper/keeper_price.go index d9615b53e..95cfb10e0 100644 --- a/x/feeds/keeper/keeper_price.go +++ b/x/feeds/keeper/keeper_price.go @@ -52,7 +52,7 @@ func (k Keeper) GetPrice(ctx sdk.Context, signalID string) types.Price { SignalID: signalID, Status: types.PRICE_STATUS_NOT_IN_CURRENT_FEEDS, Price: 0, - Timestamp: 0, + Timestamp: ctx.BlockTime().Unix(), } } diff --git a/x/feeds/keeper/keeper_price_test.go b/x/feeds/keeper/keeper_price_test.go index 085412d45..7fee498bc 100644 --- a/x/feeds/keeper/keeper_price_test.go +++ b/x/feeds/keeper/keeper_price_test.go @@ -66,7 +66,7 @@ func (suite *KeeperTestSuite) TestGetSetDeletePrices() { SignalID: "CS:ETH-USD", Status: types.PRICE_STATUS_NOT_IN_CURRENT_FEEDS, Price: 0, - Timestamp: 0, + Timestamp: suite.ctx.BlockTime().Unix(), }) prices = suite.feedsKeeper.GetPrices(ctx, []string{"CS:ATOM-USD", "CS:BAND-USD", "CS:ETH-USD"}) suite.Require().Equal(expPrices, prices)