Skip to content

Commit

Permalink
chore: test Denom
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno committed Feb 24, 2024
1 parent 90506e2 commit 3e504cf
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions pkg/config/toml_config/denom_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package toml_config_test

import (
tomlConfig "main/pkg/config/toml_config"
"main/pkg/config/types"
"testing"

"github.com/stretchr/testify/require"
)

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

denom := tomlConfig.DenomInfo{}
require.Error(t, denom.Validate())
}

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

denom := tomlConfig.DenomInfo{
Denom: "udenom",
}
require.Error(t, denom.Validate())
}

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

denom := tomlConfig.DenomInfo{
Denom: "udenom",
DisplayDenom: "denom",
}
require.NoError(t, denom.Validate())
}

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

denom := &tomlConfig.DenomInfo{
Denom: "udenom",
DisplayDenom: "denom",
DenomCoefficient: 500,
CoingeckoCurrency: "coingecko",
}
denoms := tomlConfig.DenomInfos{denom}
appConfigDenoms := denoms.ToAppConfigDenomInfos()

require.Len(t, appConfigDenoms, 1)
require.Equal(t, "udenom", appConfigDenoms[0].Denom)
require.Equal(t, "denom", appConfigDenoms[0].DisplayDenom)
require.Equal(t, int64(500), appConfigDenoms[0].DenomCoefficient)
require.Equal(t, "coingecko", appConfigDenoms[0].CoingeckoCurrency)
}

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

denom := &types.DenomInfo{
Denom: "udenom",
DisplayDenom: "denom",
DenomCoefficient: 500,
CoingeckoCurrency: "coingecko",
}
denoms := types.DenomInfos{denom}
tomlConfigDenoms := tomlConfig.TomlConfigDenomsFrom(denoms)

require.Len(t, tomlConfigDenoms, 1)
require.Equal(t, "udenom", tomlConfigDenoms[0].Denom)
require.Equal(t, "denom", tomlConfigDenoms[0].DisplayDenom)
require.Equal(t, int64(500), tomlConfigDenoms[0].DenomCoefficient)
require.Equal(t, "coingecko", tomlConfigDenoms[0].CoingeckoCurrency)
}

0 comments on commit 3e504cf

Please sign in to comment.