public static AddressV1Message read(ByteBuffer payload) throws BufferUnderflowException, ProtocolException {
        return new AddressV1Message(readAddresses(payload, 1));
    }
@Test
    public void roundtrip() {
        AddressMessage message = AddressV1Message.read(ByteBuffer.wrap(ByteUtils.parseHex(MESSAGE_HEX)));

        List<PeerAddress> addresses = message.getAddresses();
        assertEquals(4, addresses.size());
        PeerAddress a0 = addresses.get(0);
        assertEquals("2009-01-09T02:54:25Z", TimeUtils.dateTimeFormat(a0.time()));
        assertFalse(a0.getServices().hasAny());
        assertTrue(a0.getAddr() instanceof Inet4Address);
        assertEquals("0.0.0.1", a0.getAddr().getHostAddress());
        assertNull(a0.getHostname());
        assertEquals(0, a0.getPort());
        PeerAddress a1 = addresses.get(1);
        assertEquals("2039-11-22T11:22:33Z", TimeUtils.dateTimeFormat(a1.time()));
        assertEquals(Services.NODE_NETWORK, a1.getServices().bits());
        assertTrue(a1.getAddr() instanceof Inet6Address);
        assertEquals("0:0:0:0:0:0:0:1", a1.getAddr().getHostAddress());
        assertNull(a1.getHostname());
        assertEquals(0xf1, a1.getPort());
        PeerAddress a2 = addresses.get(2);
        assertEquals("2106-02-07T06:28:15Z", TimeUtils.dateTimeFormat(a2.time()));
        assertEquals(Services.NODE_WITNESS | 1 << 6 /* NODE_COMPACT_FILTERS  */
                | Services.NODE_NETWORK_LIMITED, a2.getServices().bits());
        assertTrue(a2.getAddr() instanceof Inet6Address);
        assertEquals("0:0:0:0:0:0:0:1", a2.getAddr().getHostAddress());
        assertNull(a2.getHostname());
        assertEquals(0xf1f2, a2.getPort());
        PeerAddress a3 = addresses.get(3);
        assertEquals("1970-01-01T00:00:00Z", TimeUtils.dateTimeFormat(a3.time()));
        assertFalse(a3.getServices().hasAny());
        assertNull(a3.getAddr());
        assertEquals("6hzph5hv6337r6p2.onion", a3.getHostname());
        assertEquals(0, a3.getPort());

        assertEquals(MESSAGE_HEX, ByteUtils.formatHex(message.serialize()));
    }