use of tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.EnrForkId 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));
}
use of tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.EnrForkId in project teku by ConsenSys.
the class DiscoveryNetworkTest method setForkInfo_noFutureForkScheduled.
@Test
public void setForkInfo_noFutureForkScheduled() {
discoveryNetwork.setForkInfo(currentForkInfo, Optional.empty());
final EnrForkId expectedEnrForkId = new EnrForkId(currentForkInfo.getForkDigest(spec), currentForkInfo.getFork().getCurrent_version(), SpecConfig.FAR_FUTURE_EPOCH);
verify(discoveryService).updateCustomENRField("eth2", expectedEnrForkId.sszSerialize());
}
use of tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.EnrForkId in project teku by ConsenSys.
the class DiscoveryNetworkTest method setForkInfo_futureForkScheduled.
@Test
public void setForkInfo_futureForkScheduled() {
discoveryNetwork.setForkInfo(currentForkInfo, Optional.of(nextFork));
final EnrForkId expectedEnrForkId = new EnrForkId(currentForkInfo.getForkDigest(spec), nextFork.getCurrent_version(), nextFork.getEpoch());
verify(discoveryService).updateCustomENRField("eth2", expectedEnrForkId.sszSerialize());
}
use of tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.EnrForkId in project teku by ConsenSys.
the class DiscoveryNetworkTest method setForkInfoAtInitialization.
@Test
public void setForkInfoAtInitialization() {
final SpecVersion genesisSpec = spec.getGenesisSpec();
final Bytes4 genesisForkVersion = genesisSpec.getConfig().getGenesisForkVersion();
final EnrForkId enrForkId = new EnrForkId(genesisSpec.miscHelpers().computeForkDigest(genesisForkVersion, Bytes32.ZERO), genesisForkVersion, SpecConfig.FAR_FUTURE_EPOCH);
verify(discoveryService).updateCustomENRField("eth2", enrForkId.sszSerialize());
}
use of tech.pegasys.teku.spec.datastructures.networking.libp2p.rpc.EnrForkId in project teku by ConsenSys.
the class DiscoveryNetworkTest method shouldNotConnectToPeersWhenNodeHasNoEnrForkId.
@Test
@SuppressWarnings("unchecked")
public void shouldNotConnectToPeersWhenNodeHasNoEnrForkId() {
final EnrForkId enrForkId = new EnrForkId(currentForkInfo.getForkDigest(spec), currentForkInfo.getFork().getCurrent_version(), SpecConfig.FAR_FUTURE_EPOCH);
ArgumentCaptor<Predicate<DiscoveryPeer>> peerPredicateArgumentCaptor = ArgumentCaptor.forClass(Predicate.class);
verify(connectionManager).addPeerPredicate(peerPredicateArgumentCaptor.capture());
DiscoveryPeer peer1 = createDiscoveryPeer(Optional.of(enrForkId));
assertThat(peerPredicateArgumentCaptor.getValue().test(peer1)).isFalse();
}
Aggregations