use of tech.pegasys.teku.networking.eth2.peers.Eth2Peer in project teku by ConsenSys.
the class BeaconBlocksByRootIntegrationTest method requestBlockByRootAfterPeerDisconnected.
@Test
public void requestBlockByRootAfterPeerDisconnected() throws InterruptedException, ExecutionException, TimeoutException {
final Eth2Peer peer = createPeer();
final SignedBeaconBlock block = addBlock();
final Bytes32 blockHash = block.getMessage().hashTreeRoot();
Waiter.waitFor(peer.disconnectCleanly(DisconnectReason.TOO_MANY_PEERS));
final SafeFuture<Optional<SignedBeaconBlock>> res = peer.requestBlockByRoot(blockHash);
waitFor(() -> assertThat(res).isDone());
assertThat(res).isCompletedExceptionally();
assertThatThrownBy(res::get).hasRootCauseInstanceOf(PeerDisconnectedException.class);
}
use of tech.pegasys.teku.networking.eth2.peers.Eth2Peer in project teku by ConsenSys.
the class GetMetadataIntegrationTest method requestMetadata_shouldSendLatestAttnets.
@Test
public void requestMetadata_shouldSendLatestAttnets() throws Exception {
final PeerAndNetwork peerAndNetwork = createRemotePeerAndNetwork();
final Eth2Peer peer = peerAndNetwork.getPeer();
MetadataMessage md1 = peer.requestMetadata().get(10, TimeUnit.SECONDS);
MetadataMessage md2 = peer.requestMetadata().get(10, TimeUnit.SECONDS);
assertThat(md1.getSeqNumber()).isEqualTo(md2.getSeqNumber());
assertThat(md1.getAttnets().getBitCount()).isEqualTo(0);
peerAndNetwork.getNetwork().setLongTermAttestationSubnetSubscriptions(List.of(0, 1, 8));
MetadataMessage md3 = peer.requestMetadata().get(10, TimeUnit.SECONDS);
assertThat(md3.getSeqNumber()).isGreaterThan(md2.getSeqNumber());
assertThat(md3.getAttnets().getBitCount()).isEqualTo(3);
assertThat(md3.getAttnets().getBit(0)).isTrue();
assertThat(md3.getAttnets().getBit(1)).isTrue();
assertThat(md3.getAttnets().getBit(8)).isTrue();
}
use of tech.pegasys.teku.networking.eth2.peers.Eth2Peer in project teku by ConsenSys.
the class GetMetadataIntegrationTest method requestMetadata_shouldSendLatestSyncnets.
@Test
public void requestMetadata_shouldSendLatestSyncnets() throws Exception {
final PeerAndNetwork peerAndNetwork = createRemotePeerAndNetwork(true, true);
final Eth2Peer peer = peerAndNetwork.getPeer();
MetadataMessage md1 = peer.requestMetadata().get(10, TimeUnit.SECONDS);
MetadataMessage md2 = peer.requestMetadata().get(10, TimeUnit.SECONDS);
assertThat(md1.getSeqNumber()).isEqualTo(md2.getSeqNumber());
assertThat(md1.getAttnets().getBitCount()).isEqualTo(0);
// Subscribe to some sync committee subnets
peerAndNetwork.getNetwork().subscribeToSyncCommitteeSubnetId(1);
peerAndNetwork.getNetwork().subscribeToSyncCommitteeSubnetId(2);
MetadataMessage md3 = peer.requestMetadata().get(10, TimeUnit.SECONDS);
assertThat(md3).isInstanceOf(MetadataMessageAltair.class);
final MetadataMessageAltair altairMetadata = (MetadataMessageAltair) md3;
// Check metadata
assertThat(altairMetadata.getSeqNumber()).isGreaterThan(md2.getSeqNumber());
assertThat(altairMetadata.getSyncnets().getBitCount()).isEqualTo(2);
assertThat(altairMetadata.getSyncnets().getBit(1)).isTrue();
assertThat(altairMetadata.getSyncnets().getBit(2)).isTrue();
// Unsubscribe from sync committee subnet
peerAndNetwork.getNetwork().unsubscribeFromSyncCommitteeSubnetId(2);
MetadataMessage md4 = peer.requestMetadata().get(10, TimeUnit.SECONDS);
assertThat(md4).isInstanceOf(MetadataMessageAltair.class);
final MetadataMessageAltair altairMetadata2 = (MetadataMessageAltair) md4;
// Check metadata
assertThat(altairMetadata2.getSeqNumber()).isGreaterThan(altairMetadata.getSeqNumber());
assertThat(altairMetadata2.getSyncnets().getBitCount()).isEqualTo(1);
assertThat(altairMetadata2.getSyncnets().getBit(1)).isTrue();
}
use of tech.pegasys.teku.networking.eth2.peers.Eth2Peer in project teku by ConsenSys.
the class BeaconBlocksByRangeIntegrationTest method requestBlockByRootAfterPeerDisconnected.
@Test
public void requestBlockByRootAfterPeerDisconnected() throws Exception {
final Eth2Peer peer = createPeer();
// Setup chain
peerStorage.chainUpdater().advanceChain();
final SignedBlockAndState block2 = peerStorage.chainUpdater().advanceChain();
peerStorage.chainUpdater().updateBestBlock(block2);
Waiter.waitFor(peer.disconnectCleanly(DisconnectReason.TOO_MANY_PEERS));
final SafeFuture<Optional<SignedBeaconBlock>> res = peer.requestBlockBySlot(UInt64.ONE);
waitFor(() -> assertThat(res).isDone());
assertThat(res).isCompletedExceptionally();
assertThatThrownBy(res::get).hasRootCauseInstanceOf(PeerDisconnectedException.class);
}
use of tech.pegasys.teku.networking.eth2.peers.Eth2Peer in project teku by ConsenSys.
the class BeaconBlocksByRangeIntegrationTest method shouldSendEmptyResponsePreGenesisEvent.
@Test
public void shouldSendEmptyResponsePreGenesisEvent() throws Exception {
final Eth2Peer peer = createPeer();
final List<SignedBeaconBlock> response = requestBlocks(peer);
assertThat(response).isEmpty();
}
Aggregations