neo-go/pkg/config/rpc_config_test.go
Roman Khimov 0d65071abc config: use string type for Port
6b4dd5703e made it to be a uint16 which was
somewhat important for RPC, but now it's irrelevant and the fact that it was a
string in some cases may lead to errors like these:

  failed to unmarshal config YAML: yaml: unmarshal errors:
    line 48: cannot unmarshal !!str `20011` into uint16
    line 52: cannot unmarshal !!str `40001` into uint16

So for maximum backwards compatibility we better have string here and
eventually it'll be deleted anyway.
2022-12-07 21:21:05 +03:00

24 lines
557 B
Go

package config
import (
"testing"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
)
// TestRPC_UnmarshalBasicService is aimed to check that BasicService config of
// RPC service can be properly unmarshalled. This test may be removed after
// Address and Port config fields removal.
func TestRPC_UnmarshalBasicService(t *testing.T) {
data := `
Enabled: true
Port: 10332
MaxGasInvoke: 15
`
cfg := &RPC{}
err := yaml.Unmarshal([]byte(data), &cfg)
require.NoError(t, err)
require.True(t, cfg.Enabled)
require.Equal(t, "10332", *cfg.Port)
}