From c785b117a23c3d73d3851a02a4e274f0291325c8 Mon Sep 17 00:00:00 2001 From: Sergey Date: Mon, 24 Jun 2024 01:16:38 +0300 Subject: [PATCH] chore: refactor denoms in price fetcher --- pkg/fetchers/price.go | 2 +- pkg/fetchers/price_test.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/fetchers/price.go b/pkg/fetchers/price.go index 3430856..7ad1fca 100644 --- a/pkg/fetchers/price.go +++ b/pkg/fetchers/price.go @@ -75,7 +75,7 @@ func (q *PriceFetcher) ProcessDenoms(chainName string, denoms config.DenomInfos, for _, denom := range denoms { // using coingecko response if rate, ok := currenciesRates[denom.CoingeckoCurrency]; ok { - q.CurrenciesRatesToChains[chainName][denom.Denom] = rate + q.CurrenciesRatesToChains[chainName][denom.DisplayDenom] = rate continue } } diff --git a/pkg/fetchers/price_test.go b/pkg/fetchers/price_test.go index 5210bea..4a06b4b 100644 --- a/pkg/fetchers/price_test.go +++ b/pkg/fetchers/price_test.go @@ -51,7 +51,7 @@ func TestPriceFetcherProviderCoingeckoError(t *testing.T) { chains := []*configPkg.Chain{{ Name: "chain", - Denoms: configPkg.DenomInfos{{Denom: "denom", CoingeckoCurrency: "cosmos"}}, + Denoms: configPkg.DenomInfos{{Denom: "uatom", DisplayDenom: "atom", CoingeckoCurrency: "cosmos"}}, }} config := &configPkg.Config{Chains: chains} logger := loggerPkg.GetNopLogger() @@ -89,7 +89,7 @@ func TestPriceFetcherProviderCoingeckoSuccess(t *testing.T) { chains := []*configPkg.Chain{{ Name: "chain", - Denoms: configPkg.DenomInfos{{Denom: "denom", CoingeckoCurrency: "cosmos"}}, + Denoms: configPkg.DenomInfos{{Denom: "uatom", DisplayDenom: "atom", CoingeckoCurrency: "cosmos"}}, }} config := &configPkg.Config{Chains: chains} logger := loggerPkg.GetNopLogger() @@ -112,7 +112,7 @@ func TestPriceFetcherProviderCoingeckoSuccess(t *testing.T) { chainData, ok := balanceData.Prices["chain"] assert.True(t, ok) - denomData, ok := chainData["denom"] + denomData, ok := chainData["atom"] assert.True(t, ok) assert.InEpsilon(t, 6.71, denomData, 0.01) } @@ -132,7 +132,7 @@ func TestPriceFetcherConsumerCoingeckoSuccess(t *testing.T) { Name: "chain", ConsumerChains: []*configPkg.ConsumerChain{{ Name: "consumer", - Denoms: configPkg.DenomInfos{{Denom: "denom", CoingeckoCurrency: "cosmos"}}, + Denoms: configPkg.DenomInfos{{Denom: "uatom", DisplayDenom: "atom", CoingeckoCurrency: "cosmos"}}, }}, }} config := &configPkg.Config{Chains: chains} @@ -156,7 +156,7 @@ func TestPriceFetcherConsumerCoingeckoSuccess(t *testing.T) { chainData, ok := balanceData.Prices["consumer"] assert.True(t, ok) - denomData, ok := chainData["denom"] + denomData, ok := chainData["atom"] assert.True(t, ok) assert.InEpsilon(t, 6.71, denomData, 0.01) }