2021-07-06 11:27:54 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
2022-02-02 13:28:08 +00:00
|
|
|
"path/filepath"
|
2021-07-06 11:27:54 +00:00
|
|
|
"testing"
|
|
|
|
|
2022-12-23 17:35:35 +00:00
|
|
|
"github.com/TrueCloudLab/frostfs-node/pkg/innerring"
|
2021-07-06 11:27:54 +00:00
|
|
|
"github.com/spf13/viper"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGenerateConfigExample(t *testing.T) {
|
|
|
|
const (
|
|
|
|
n = 10
|
2022-12-23 17:35:35 +00:00
|
|
|
appDir = "/home/example/.frostfs"
|
2021-07-06 11:27:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
configText, err := generateConfigExample(appDir, n)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
v := viper.New()
|
|
|
|
v.SetConfigType("yml")
|
|
|
|
|
|
|
|
require.NoError(t, v.ReadConfig(bytes.NewBufferString(configText)))
|
|
|
|
|
|
|
|
require.Equal(t, "https://neo.rpc.node:30333", v.GetString("rpc-endpoint"))
|
2022-02-02 13:28:08 +00:00
|
|
|
require.Equal(t, filepath.Join(appDir, "alphabet-wallets"), v.GetString("alphabet-wallets"))
|
2021-07-06 11:27:54 +00:00
|
|
|
require.Equal(t, 67108864, v.GetInt("network.max_object_size"))
|
|
|
|
require.Equal(t, 240, v.GetInt("network.epoch_duration"))
|
2021-08-03 12:04:38 +00:00
|
|
|
require.Equal(t, 100000000, v.GetInt("network.basic_income_rate"))
|
|
|
|
require.Equal(t, 10000, v.GetInt("network.fee.audit"))
|
|
|
|
require.Equal(t, 10000000000, v.GetInt("network.fee.candidate"))
|
|
|
|
require.Equal(t, 1000, v.GetInt("network.fee.container"))
|
|
|
|
require.Equal(t, 100000000, v.GetInt("network.fee.withdraw"))
|
2021-07-06 11:27:54 +00:00
|
|
|
|
|
|
|
var i innerring.GlagoliticLetter
|
|
|
|
for i = 0; i < innerring.GlagoliticLetter(n); i++ {
|
|
|
|
key := "credentials." + i.String()
|
|
|
|
require.Equal(t, "password", v.GetString(key))
|
|
|
|
}
|
2022-04-06 09:36:35 +00:00
|
|
|
require.Equal(t, "password", v.GetString("credentials.contract"))
|
2021-07-06 11:27:54 +00:00
|
|
|
|
|
|
|
key := "credentials." + i.String()
|
|
|
|
require.Equal(t, "", v.GetString(key))
|
|
|
|
}
|