Skip to content

Commit

Permalink
chore: refactor denoms in price fetcher
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno committed Jun 23, 2024
1 parent deb5543 commit c785b11
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/fetchers/price.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/fetchers/price_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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)
}
Expand All @@ -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}
Expand All @@ -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)
}

0 comments on commit c785b11

Please sign in to comment.