use of tech.pegasys.teku.api.schema.altair.SignedBeaconBlockAltair 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.schema.altair.SignedBeaconBlockAltair in project teku by ConsenSys.
the class TekuNode method waitForFullSyncCommitteeAggregate.
public void waitForFullSyncCommitteeAggregate() {
LOG.debug("Wait for full sync committee aggregates");
waitFor(() -> {
final Optional<SignedBlock> block = fetchHeadBlock();
assertThat(block).isPresent();
assertThat(block.get()).isInstanceOf(SignedBeaconBlockAltair.class);
final SignedBeaconBlockAltair altairBlock = (SignedBeaconBlockAltair) block.get();
final int syncCommitteeSize = spec.getSyncCommitteeSize(altairBlock.getMessage().slot);
final SszBitvectorSchema<SszBitvector> syncCommitteeSchema = SszBitvectorSchema.create(syncCommitteeSize);
final Bytes syncCommitteeBits = altairBlock.getMessage().getBody().syncAggregate.syncCommitteeBits;
final int actualSyncBitCount = syncCommitteeSchema.sszDeserialize(syncCommitteeBits).getBitCount();
final double percentageOfBitsSet = actualSyncBitCount == syncCommitteeSize ? 1.0 : actualSyncBitCount / (double) syncCommitteeSize;
if (percentageOfBitsSet < 1.0) {
LOG.debug(String.format("Sync committee bits are only %s%% full, expecting %s%%: %s", percentageOfBitsSet * 100, 100, syncCommitteeBits));
}
assertThat(percentageOfBitsSet >= 1.0).isTrue();
}, 5, MINUTES);
}
Aggregations