[#280] ir: Add fee config tests
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
22d47376a6
commit
3b64dffda2
1 changed files with 68 additions and 0 deletions
68
pkg/innerring/config/fee_test.go
Normal file
68
pkg/innerring/config/fee_test.go
Normal file
|
@ -0,0 +1,68 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("all set", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
file := strings.NewReader(
|
||||
`
|
||||
fee:
|
||||
main_chain: 50000000
|
||||
side_chain: 200000000
|
||||
named_container_register: 2500000000
|
||||
`,
|
||||
)
|
||||
v := viper.New()
|
||||
v.SetConfigType("yaml")
|
||||
err := v.ReadConfig(file)
|
||||
require.NoError(t, err, "read config file failed")
|
||||
|
||||
config := NewFeeConfig(v)
|
||||
require.Equal(t, fixedn.Fixed8(50000000), config.MainChainFee(), "main chain fee invalid")
|
||||
require.Equal(t, fixedn.Fixed8(200000000), config.SideChainFee(), "side chain fee invalid")
|
||||
require.Equal(t, fixedn.Fixed8(2500000000), config.NamedContainerRegistrationFee(), "named container register fee invalid")
|
||||
})
|
||||
|
||||
t.Run("nothing set", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
file := strings.NewReader("")
|
||||
v := viper.New()
|
||||
v.SetConfigType("yaml")
|
||||
err := v.ReadConfig(file)
|
||||
require.NoError(t, err, "read config file failed")
|
||||
|
||||
config := NewFeeConfig(v)
|
||||
require.Equal(t, fixedn.Fixed8(0), config.MainChainFee(), "main chain fee invalid")
|
||||
require.Equal(t, fixedn.Fixed8(0), config.SideChainFee(), "side chain fee invalid")
|
||||
require.Equal(t, fixedn.Fixed8(0), config.NamedContainerRegistrationFee(), "named container register fee invalid")
|
||||
})
|
||||
|
||||
t.Run("partially set", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
file := strings.NewReader(
|
||||
`
|
||||
fee:
|
||||
main_chain: 10
|
||||
`,
|
||||
)
|
||||
v := viper.New()
|
||||
v.SetConfigType("yaml")
|
||||
err := v.ReadConfig(file)
|
||||
require.NoError(t, err, "read config file failed")
|
||||
|
||||
config := NewFeeConfig(v)
|
||||
require.Equal(t, fixedn.Fixed8(10), config.MainChainFee(), "main chain fee invalid")
|
||||
require.Equal(t, fixedn.Fixed8(0), config.SideChainFee(), "side chain fee invalid")
|
||||
require.Equal(t, fixedn.Fixed8(0), config.NamedContainerRegistrationFee(), "named container register fee invalid")
|
||||
})
|
||||
|
||||
}
|
Loading…
Reference in a new issue