### Question:
MultiaddrUtil { static Multiaddr fromInetSocketAddress(final InetSocketAddress address) { return fromInetSocketAddress(address, "tcp"); }  static Multiaddr fromDiscoveryPeer(final DiscoveryPeer peer); static Multiaddr fromDiscoveryPeerAsUdp(final DiscoveryPeer peer); static Multiaddr fromInetSocketAddress(
      final InetSocketAddress address, final NodeId nodeId);  }### Answer:
@Test public void fromInetSocketAddress_shouldConvertIpV4Peer() throws Exception { final byte[] ipAddress = {123, 34, 58, 22}; final int port = 5883; final InetSocketAddress address = new InetSocketAddress(InetAddress.getByAddress(ipAddress), port); final Multiaddr result = MultiaddrUtil.fromInetSocketAddress(address); assertThat(result).isEqualTo(Multiaddr.fromString("/ip4/123.34.58.22/tcp/5883/")); assertThat(result.getComponent(Protocol.IP4)).isEqualTo(ipAddress); assertThat(result.getComponent(Protocol.TCP)).isEqualTo(Protocol.TCP.addressToBytes("5883")); assertThat(result.getComponent(Protocol.P2P)).isNull(); }
@Test public void fromInetSocketAddress_shouldConvertIpV6Peer() throws Exception { final byte[] ipAddress = Bytes.fromHexString("0x33000004500007800000001200000001").toArray(); final int port = 5883; final InetSocketAddress address = new InetSocketAddress(InetAddress.getByAddress(ipAddress), port); final Multiaddr result = MultiaddrUtil.fromInetSocketAddress(address); assertThat(result).isEqualTo(Multiaddr.fromString("/ip6/3300:4:5000:780:0:12:0:1/tcp/5883/")); assertThat(result.getComponent(Protocol.IP6)).isEqualTo(ipAddress); assertThat(result.getComponent(Protocol.TCP)).isEqualTo(Protocol.TCP.addressToBytes("5883")); assertThat(result.getComponent(Protocol.P2P)).isNull(); }