frostfs-node/pkg/network/address_test.go
Alex Vanin e158497560 [#43] cmd/neofs-node: Support hostnames with dns, ipv4 and ipv6 addresses
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-10-02 11:25:36 +03:00

30 lines
511 B
Go

package network
import (
"strings"
"testing"
"github.com/multiformats/go-multiaddr"
"github.com/stretchr/testify/require"
)
func TestAddress_NetAddr(t *testing.T) {
ip := "127.0.0.1"
port := "8080"
ma, err := multiaddr.NewMultiaddr(strings.Join([]string{
"/ip4",
ip,
"tcp",
port,
}, "/"))
require.NoError(t, err)
addr, err := AddressFromString(ma.String())
require.NoError(t, err)
netAddr, err := addr.IPAddrString()
require.NoError(t, err)
require.Equal(t, ip+":"+port, netAddr)
}