diff --git a/pkg/netmap/network_info.go b/pkg/netmap/network_info.go index ba3f204a..d4a6bdbc 100644 --- a/pkg/netmap/network_info.go +++ b/pkg/netmap/network_info.go @@ -9,6 +9,8 @@ import ( type NetworkInfo netmap.NetworkInfo // NewNetworkInfoFromV2 wraps v2 NetworkInfo message to NetworkInfo. +// +// Nil netmap.NetworkInfo converts to nil. func NewNetworkInfoFromV2(iV2 *netmap.NetworkInfo) *NetworkInfo { return (*NetworkInfo)(iV2) } @@ -19,6 +21,8 @@ func NewNetworkInfo() *NetworkInfo { } // ToV2 converts NetworkInfo to v2 NetworkInfo. +// +// Nil NetworkInfo converts to nil. func (i *NetworkInfo) ToV2() *netmap.NetworkInfo { return (*netmap.NetworkInfo)(i) } diff --git a/pkg/netmap/network_info_test.go b/pkg/netmap/network_info_test.go index bb8643fe..04234e8b 100644 --- a/pkg/netmap/network_info_test.go +++ b/pkg/netmap/network_info_test.go @@ -51,3 +51,17 @@ func TestNetworkInfoEncoding(t *testing.T) { require.Equal(t, i, i2) }) } + +func TestNewNetworkInfoFromV2(t *testing.T) { + t.Run("nil", func(t *testing.T) { + require.Nil(t, NewNetworkInfoFromV2(nil)) + }) +} + +func TestNetworkInfo_ToV2(t *testing.T) { + t.Run("nil", func(t *testing.T) { + var x *NetworkInfo + + require.Nil(t, x.ToV2()) + }) +}