2021-06-01 14:33:45 +00:00
|
|
|
package morphconfig_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
|
|
|
morphconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/morph"
|
|
|
|
configtest "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/test"
|
2022-07-18 13:41:35 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
2021-06-01 14:33:45 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMorphSection(t *testing.T) {
|
|
|
|
t.Run("defaults", func(t *testing.T) {
|
|
|
|
empty := configtest.EmptyConfig()
|
|
|
|
|
|
|
|
require.Panics(t, func() { morphconfig.RPCEndpoint(empty) })
|
|
|
|
require.Equal(t, morphconfig.DialTimeoutDefault, morphconfig.DialTimeout(empty))
|
2022-08-16 11:59:30 +00:00
|
|
|
require.Equal(t, morphconfig.CacheTTLDefault, morphconfig.CacheTTL(empty))
|
2021-06-01 14:33:45 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
const path = "../../../../config/example/node"
|
|
|
|
|
|
|
|
var (
|
2022-07-18 13:41:35 +00:00
|
|
|
rpcs = []client.Endpoint{
|
2022-08-02 11:31:21 +00:00
|
|
|
{"wss://rpc1.morph.fs.neo.org:40341/ws", 1},
|
|
|
|
{"wss://rpc2.morph.fs.neo.org:40341/ws", 2},
|
2021-06-01 14:33:45 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
var fileConfigTest = func(c *config.Config) {
|
|
|
|
require.Equal(t, rpcs, morphconfig.RPCEndpoint(c))
|
|
|
|
require.Equal(t, 30*time.Second, morphconfig.DialTimeout(c))
|
2022-08-16 11:59:30 +00:00
|
|
|
require.Equal(t, 15*time.Second, morphconfig.CacheTTL(c))
|
2021-06-01 14:33:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
configtest.ForEachFileType(path, fileConfigTest)
|
|
|
|
|
|
|
|
t.Run("ENV", func(t *testing.T) {
|
|
|
|
configtest.ForEnvFileType(path, fileConfigTest)
|
|
|
|
})
|
|
|
|
}
|