use of tech.pegasys.teku.networking.eth2.rpc.core.RpcException.InvalidRpcMethodVersion in project teku by ConsenSys.
the class BeaconBlocksByRangeMessageHandlerTest method validateRequest_altairSpec_v1RequestForRangeOfBlocksAcrossForkBoundary.
@Test
public void validateRequest_altairSpec_v1RequestForRangeOfBlocksAcrossForkBoundary() {
final Spec spec = TestSpecFactory.createMinimalWithAltairForkEpoch(UInt64.valueOf(4));
final BeaconBlocksByRangeMessageHandler handler = new BeaconBlocksByRangeMessageHandler(spec, combinedChainDataClient, maxRequestSize);
final Optional<RpcException> result = handler.validateRequest(V1_PROTOCOL_ID, new BeaconBlocksByRangeRequestMessage(UInt64.valueOf(30), UInt64.valueOf(10), ONE));
assertThat(result).contains(new InvalidRpcMethodVersion("Must request altair blocks using v2 protocol"));
}
use of tech.pegasys.teku.networking.eth2.rpc.core.RpcException.InvalidRpcMethodVersion in project teku by ConsenSys.
the class BeaconBlocksByRangeMessageHandler method validateRequest.
@Override
public Optional<RpcException> validateRequest(final String protocolId, final BeaconBlocksByRangeRequestMessage request) {
final int version = BeaconChainMethodIds.extractBeaconBlocksByRangeVersion(protocolId);
final SpecMilestone latestMilestoneRequested = spec.getForkSchedule().getSpecMilestoneAtSlot(request.getMaxSlot());
final boolean isAltairActive = latestMilestoneRequested.isGreaterThanOrEqualTo(SpecMilestone.ALTAIR);
if (version == 1 && isAltairActive) {
return Optional.of(new InvalidRpcMethodVersion("Must request altair blocks using v2 protocol"));
}
return Optional.empty();
}
use of tech.pegasys.teku.networking.eth2.rpc.core.RpcException.InvalidRpcMethodVersion in project teku by ConsenSys.
the class BeaconBlocksByRangeMessageHandlerTest method validateRequest_altairSpec_v1RequestForAltairBlock.
@Test
public void validateRequest_altairSpec_v1RequestForAltairBlock() {
final Spec spec = TestSpecFactory.createMinimalWithAltairForkEpoch(UInt64.valueOf(4));
final BeaconBlocksByRangeMessageHandler handler = new BeaconBlocksByRangeMessageHandler(spec, combinedChainDataClient, maxRequestSize);
final Optional<RpcException> result = handler.validateRequest(V1_PROTOCOL_ID, new BeaconBlocksByRangeRequestMessage(UInt64.valueOf(32), ONE, ONE));
assertThat(result).contains(new InvalidRpcMethodVersion("Must request altair blocks using v2 protocol"));
}
use of tech.pegasys.teku.networking.eth2.rpc.core.RpcException.InvalidRpcMethodVersion in project teku by ConsenSys.
the class BeaconBlocksByRootMessageHandlerTest method validateResponse_altairSpec_v1RequestForAltairBlock.
@Test
public void validateResponse_altairSpec_v1RequestForAltairBlock() {
final Optional<RpcException> result = handler.validateResponse(V1_PROTOCOL_ID, chainUpdater.advanceChain(altairForkSlot).getBlock());
assertThat(result).contains(new InvalidRpcMethodVersion("Must request altair blocks using v2 protocol"));
}
use of tech.pegasys.teku.networking.eth2.rpc.core.RpcException.InvalidRpcMethodVersion in project teku by ConsenSys.
the class BeaconBlocksByRootMessageHandler method validateResponse.
@VisibleForTesting
Optional<RpcException> validateResponse(final String protocolId, final SignedBeaconBlock response) {
final int version = BeaconChainMethodIds.extractBeaconBlocksByRootVersion(protocolId);
final SpecMilestone milestoneAtResponse = spec.getForkSchedule().getSpecMilestoneAtSlot(response.getSlot());
final boolean isAltairActive = milestoneAtResponse.isGreaterThanOrEqualTo(SpecMilestone.ALTAIR);
if (version == 1 && isAltairActive) {
return Optional.of(new InvalidRpcMethodVersion("Must request altair blocks using v2 protocol"));
}
return Optional.empty();
}
Aggregations