use of org.hyperledger.besu.ethereum.p2p.discovery.internal.ENRResponsePacketData in project besu by hyperledger.
the class PeerDiscoveryPacketPcapSedesTest method testUDPENRResponseSerializeDeserialize.
@Test
public void testUDPENRResponseSerializeDeserialize() {
final byte[] data = Hex.decode(enrResponseHexData);
final Packet packet = Packet.decode(Buffer.buffer(data));
assertThat(packet.getType()).isNotNull();
assertThat(packet.getNodeId()).isNotNull();
assertThat(packet.getNodeId().toArray()).hasSize(64);
assertThat(packet.getType()).isEqualTo(PacketType.ENR_RESPONSE);
final ENRResponsePacketData enrResponsePacketData = packet.getPacketData(ENRResponsePacketData.class).orElse(null);
assertThat(enrResponsePacketData).isNotNull();
assertThat(enrResponsePacketData.getEnr()).isNotNull();
assertThat(enrResponsePacketData.getEnr().getSeq()).isGreaterThan(UInt64.ZERO);
assertThat(enrResponsePacketData.getEnr().getSignature()).isNotNull();
assertThat(enrResponsePacketData.getRequestHash()).isNotNull();
assertThat(enrResponsePacketData.getRequestHash().toArray()).hasSize(32);
final byte[] encoded = packet.encode().getBytes();
assertThat(encoded).isEqualTo(data);
}
Aggregations