Skip to content

Commit

Permalink
Merge branch 'main' into tyler/blo-1459-simapp-doesnt-work-with-xupgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Johnson authored Jul 2, 2024
2 parents c05300c + 0db197c commit 6ff52fb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
7 changes: 6 additions & 1 deletion x/marketmap/types/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ import (
// 2. Ensure that each provider config has a valid corresponding ticker.
// 3. Ensure that all normalization markets are enabled.
func (mm *MarketMap) ValidateBasic() error {
for _, market := range mm.Markets {
for ticker, market := range mm.Markets {
if err := market.ValidateBasic(); err != nil {
return err
}

// expect that the ticker (index) is equal to the market.Ticker.String()
if ticker != market.Ticker.String() {
return fmt.Errorf("ticker %s does not match market.Ticker.String() %s", ticker, market.Ticker.String())
}

for _, providerConfig := range market.ProviderConfigs {
if providerConfig.NormalizeByPair != nil {
normalizeMarket, found := mm.Markets[providerConfig.NormalizeByPair.String()]
Expand Down
21 changes: 21 additions & 0 deletions x/marketmap/types/market_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,27 @@ func TestMarketMapValidateBasic(t *testing.T) {
},
expectErr: true,
},
{
name: "market-map with invalid key",
marketMap: types.MarketMap{
Markets: map[string]types.Market{
ethusd.String(): {
Ticker: types.Ticker{
CurrencyPair: btcusdtCP,
Decimals: 8,
MinProviderCount: 1,
},
ProviderConfigs: []types.ProviderConfig{
{
Name: coinbase.Name,
OffChainTicker: "BTC-USD",
},
},
},
},
},
expectErr: true,
},
{
name: "valid single provider",
marketMap: types.MarketMap{
Expand Down

0 comments on commit 6ff52fb

Please sign in to comment.