### Question:
MultiaddrUtil { public static Multiaddr fromDiscoveryPeer(final DiscoveryPeer peer) { return fromInetSocketAddress(peer.getNodeAddress(), getNodeId(peer)); }  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 fromDiscoveryPeer_shouldConvertIpV4Peer() throws Exception { final byte[] ipAddress = {123, 34, 58, 22}; final int port = 5883; final DiscoveryPeer peer = new DiscoveryPeer( PUB_KEY, new InetSocketAddress(InetAddress.getByAddress(ipAddress), port), ENR_FORK_ID, PERSISTENT_SUBNETS); final Multiaddr result = MultiaddrUtil.fromDiscoveryPeer(peer); assertThat(result).isEqualTo(Multiaddr.fromString("/ip4/123.34.58.22/tcp/5883/p2p/" + PEER_ID)); assertThat(result.getComponent(Protocol.IP4)).isEqualTo(ipAddress); assertThat(result.getComponent(Protocol.TCP)).isEqualTo(Protocol.TCP.addressToBytes("5883")); assertThat(result.getComponent(Protocol.P2P)).isEqualTo(NODE_ID.toBytes().toArrayUnsafe()); }
@Test public void fromDiscoveryPeer_shouldConvertIpV6Peer() throws Exception { final byte[] ipAddress = Bytes.fromHexString("0x33000004500007800000001200000001").toArray(); final int port = 5883; final DiscoveryPeer peer = new DiscoveryPeer( PUB_KEY, new InetSocketAddress(InetAddress.getByAddress(ipAddress), port), ENR_FORK_ID, PERSISTENT_SUBNETS); final Multiaddr result = MultiaddrUtil.fromDiscoveryPeer(peer); assertThat(result) .isEqualTo(Multiaddr.fromString("/ip6/3300:4:5000:780:0:12:0:1/tcp/5883/p2p/" + PEER_ID)); assertThat(result.getComponent(Protocol.IP6)).isEqualTo(ipAddress); assertThat(result.getComponent(Protocol.TCP)).isEqualTo(Protocol.TCP.addressToBytes("5883")); assertThat(result.getComponent(Protocol.P2P)).isEqualTo(NODE_ID.toBytes().toArrayUnsafe()); }
@Test public void fromDiscoveryPeer_shouldConvertRealPeer() throws Exception { final DiscoveryPeer peer = new DiscoveryPeer( Bytes.fromHexString( "0x03B86ED9F747A7FA99963F39E3B176B45E9E863108A2D145EA3A4E76D8D0935194"), new InetSocketAddress(InetAddress.getByAddress(new byte[] {127, 0, 0, 1}), 9000), ENR_FORK_ID, PERSISTENT_SUBNETS); final Multiaddr expectedMultiAddr = Multiaddr.fromString( "/ip4/127.0.0.1/tcp/9000/p2p/16Uiu2HAmR4wQRGWgCNy5uzx7HfuV59Q6X1MVzBRmvreuHgEQcCnF"); assertThat(MultiaddrUtil.fromDiscoveryPeer(peer)).isEqualTo(expectedMultiAddr); }