use of tech.pegasys.teku.api.response.v2.beacon.GetBlockResponseV2 in project teku by ConsenSys.
the class GetBlockV2IntegrationTest method shouldGetAltairBlock.
@Test
public void shouldGetAltairBlock() throws IOException {
startRestAPIAtGenesis(SpecMilestone.ALTAIR);
final List<SignedBlockAndState> created = createBlocksAtSlots(10);
final Response response = get("head");
final GetBlockResponseV2 body = jsonProvider.jsonToObject(response.body().string(), GetBlockResponseV2.class);
assertThat(body.getVersion()).isEqualTo(Version.altair);
assertThat(body.getData()).isInstanceOf(SignedBeaconBlockAltair.class);
final SignedBeaconBlockAltair data = (SignedBeaconBlockAltair) body.getData();
assertThat(data.signature.toHexString()).isEqualTo(created.get(0).getBlock().getSignature().toString());
assertThat(data.getMessage().asInternalBeaconBlock(spec).getRoot().toHexString()).isEqualTo(created.get(0).getBlock().getMessage().getRoot().toHexString());
assertThat(data.getMessage().getBody().syncAggregate.syncCommitteeBits).isEqualTo(Bytes.fromHexString("0x00000000"));
assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.altair.name());
}
use of tech.pegasys.teku.api.response.v2.beacon.GetBlockResponseV2 in project teku by ConsenSys.
the class GetBlock method handleJsonResult.
private Optional<String> handleJsonResult(Context ctx, final ObjectAndMetaData<SignedBeaconBlock> response) throws JsonProcessingException {
final Version version = Version.fromMilestone(response.getMilestone());
ctx.header(HEADER_CONSENSUS_VERSION, version.name());
return Optional.of(jsonProvider.objectToJSON(new GetBlockResponseV2(version, response.isExecutionOptimisticForApi(), response.getData())));
}
use of tech.pegasys.teku.api.response.v2.beacon.GetBlockResponseV2 in project teku by ConsenSys.
the class GetBlockV2IntegrationTest method shouldGetBlock.
@Test
public void shouldGetBlock() throws IOException {
startRestAPIAtGenesis(SpecMilestone.PHASE0);
final List<SignedBlockAndState> created = createBlocksAtSlots(10);
final Response response = get("head");
final GetBlockResponseV2 body = jsonProvider.jsonToObject(response.body().string(), GetBlockResponseV2.class);
assertThat(body.getVersion()).isEqualTo(Version.phase0);
assertThat(body.data).isInstanceOf(SignedBeaconBlockPhase0.class);
final SignedBeaconBlockPhase0 data = (SignedBeaconBlockPhase0) body.getData();
final SignedBlockAndState block = created.get(0);
assertThat(data).isEqualTo(SignedBeaconBlock.create(block.getBlock()));
assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.phase0.name());
}
Aggregations