Skip to content

Commit

Permalink
chore: add populate validator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno committed Jul 15, 2024
1 parent 104b67b commit 87bcee9
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions pkg/data_fetcher/populate_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,56 @@ func TestDataFetcherFetchValidatorSuccessfullyFetched(t *testing.T) {
require.NotNil(t, data)
require.Equal(t, "cosmosvaloper1xqz9pemz5e5zycaa89kys5aw6m8rhgsvw4328e", data.OperatorAddress)
}

//nolint:paralleltest // disabled due to httpmock usage
func TestDataFetcherPopulateValidatorNotPresent(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()

config := &configPkg.AppConfig{
Chains: types.Chains{
{Name: "chain"},
},
Metrics: configPkg.MetricsConfig{Enabled: false},
}

filesystem := &fs.MockFs{}
logger := loggerPkg.GetNopLogger()
aliasManager := aliasManagerPkg.NewAliasManager(logger, config, filesystem)
metricsManager := metrics.NewManager(logger, config.Metrics)
dataFetcher := NewDataFetcher(logger, config, aliasManager, metricsManager)

validator := &types.Link{Value: "address"}

dataFetcher.PopulateValidator(config.Chains[0], validator)
require.Empty(t, validator.Title)
}

func TestDataFetcherPopulateValidatorPresent(t *testing.T) {
t.Parallel()

config := &configPkg.AppConfig{
Chains: types.Chains{
{Name: "chain"},
},
Metrics: configPkg.MetricsConfig{Enabled: false},
AliasesPath: "path.toml",
}

filesystem := &fs.MockFs{}
logger := loggerPkg.GetNopLogger()
aliasManager := aliasManagerPkg.NewAliasManager(logger, config, filesystem)
metricsManager := metrics.NewManager(logger, config.Metrics)
dataFetcher := NewDataFetcher(logger, config, aliasManager, metricsManager)

dataFetcher.Cache.Set("chain_validator_address", &responses.Validator{
Description: responses.ValidatorDescription{
Moniker: "🐹 Quokka Stake",
},
})

validator := &types.Link{Value: "address"}

dataFetcher.PopulateValidator(config.Chains[0], validator)
require.Equal(t, "🐹 Quokka Stake", validator.Title)
}

0 comments on commit 87bcee9

Please sign in to comment.