use of org.ethereum.beacon.discovery.schema.EnrField in project xdagj by XDagger.
the class Libp2pUtilsTest method createNodeRecord.
private NodeRecord createNodeRecord(final EnrField... fields) {
final ArrayList<EnrField> fieldList = new ArrayList<>(Arrays.asList(fields));
fieldList.add(new EnrField(EnrField.ID, IdentitySchema.V4));
fieldList.add(new EnrField(EnrField.PKEY_SECP256K1, PUB_KEY));
return NodeRecordFactory.DEFAULT.createFromValues(UInt64.ZERO, fieldList);
}
use of org.ethereum.beacon.discovery.schema.EnrField in project teku by ConsenSys.
the class NodeRecordConverterTest method shouldConvertAttnets.
@Test
public void shouldConvertAttnets() {
SszBitvector persistentSubnets = ATT_SUBNET_SCHEMA.ofBits(1, 8, 14, 32);
Bytes encodedPersistentSubnets = persistentSubnets.sszSerialize();
final Optional<DiscoveryPeer> result = convertNodeRecordWithFields(new EnrField(EnrField.IP_V6, IPV6_LOCALHOST), new EnrField(EnrField.TCP_V6, 1234), new EnrField(ATTESTATION_SUBNET_ENR_FIELD, encodedPersistentSubnets));
assertThat(result).contains(new DiscoveryPeer(PUB_KEY, new InetSocketAddress("::1", 1234), ENR_FORK_ID, persistentSubnets, SYNCNETS));
}
use of org.ethereum.beacon.discovery.schema.EnrField in project teku by ConsenSys.
the class NodeRecordConverterTest method shouldConvertIpV6Record.
@Test
public void shouldConvertIpV6Record() {
final Optional<DiscoveryPeer> result = convertNodeRecordWithFields(new EnrField(EnrField.IP_V6, IPV6_LOCALHOST), new EnrField(EnrField.TCP_V6, 1234));
assertThat(result).contains(new DiscoveryPeer(PUB_KEY, new InetSocketAddress("::1", 1234), ENR_FORK_ID, ATTNETS, SYNCNETS));
}
use of org.ethereum.beacon.discovery.schema.EnrField in project teku by ConsenSys.
the class NodeRecordConverterTest method shouldConvertIpV4Record.
@Test
public void shouldConvertIpV4Record() {
// IP address bytes are unsigned. Make sure we handle that correctly.
final Optional<DiscoveryPeer> result = convertNodeRecordWithFields(new EnrField(EnrField.IP_V4, Bytes.wrap(new byte[] { -127, 24, 31, 22 })), new EnrField(EnrField.TCP, 1234));
assertThat(result).contains(new DiscoveryPeer(PUB_KEY, new InetSocketAddress("129.24.31.22", 1234), ENR_FORK_ID, ATTNETS, SYNCNETS));
}
use of org.ethereum.beacon.discovery.schema.EnrField in project teku by ConsenSys.
the class NodeRecordConverterTest method shouldConvertEnrForkId.
@Test
public void shouldConvertEnrForkId() {
EnrForkId enrForkId = new DataStructureUtil().randomEnrForkId();
Bytes encodedForkId = enrForkId.sszSerialize();
final Optional<DiscoveryPeer> result = convertNodeRecordWithFields(new EnrField(EnrField.IP_V6, IPV6_LOCALHOST), new EnrField(EnrField.TCP_V6, 1234), new EnrField(ETH2_ENR_FIELD, encodedForkId));
assertThat(result).contains(new DiscoveryPeer(PUB_KEY, new InetSocketAddress("::1", 1234), Optional.of(enrForkId), ATTNETS, SYNCNETS));
}
Aggregations