use of tech.pegasys.teku.api.response.v1.beacon.GetStateCommitteesResponse in project teku by ConsenSys.
the class GetStateCommitteesTest method shouldGetCommitteesForNextEpoch.
@Test
public void shouldGetCommitteesForNextEpoch() throws IOException {
final Response response = get("head", Map.of("epoch", "1"));
assertThat(response.code()).isEqualTo(SC_OK);
final GetStateCommitteesResponse body = jsonProvider.jsonToObject(response.body().string(), GetStateCommitteesResponse.class);
final List<EpochCommitteeResponse> data = body.data;
data.forEach(committee -> {
assertThat(committee.slot).isGreaterThanOrEqualTo(UInt64.valueOf(specConfig.getSlotsPerEpoch()));
assertThat(committee.slot).isLessThan(UInt64.valueOf(specConfig.getSlotsPerEpoch() * 2L));
});
assertThat(data.size()).isEqualTo(8);
}
use of tech.pegasys.teku.api.response.v1.beacon.GetStateCommitteesResponse in project teku by ConsenSys.
the class GetStateCommitteesTest method shouldGetCommitteesWithNoQueryParameters.
@Test
public void shouldGetCommitteesWithNoQueryParameters() throws IOException {
final Response response = get("head", emptyMap());
assertThat(response.code()).isEqualTo(SC_OK);
final GetStateCommitteesResponse body = jsonProvider.jsonToObject(response.body().string(), GetStateCommitteesResponse.class);
final List<EpochCommitteeResponse> data = body.data;
assertThat(data).isNotEmpty();
}
use of tech.pegasys.teku.api.response.v1.beacon.GetStateCommitteesResponse in project teku by ConsenSys.
the class GetStateCommitteesTest method shouldGetCommitteesForSingleIndexAndSlotAndEpoch.
@Test
public void shouldGetCommitteesForSingleIndexAndSlotAndEpoch() throws IOException {
final Response response = get("head", Map.of("index", "0", "slot", "9", "epoch", "1"));
assertThat(response.code()).isEqualTo(SC_OK);
final GetStateCommitteesResponse body = jsonProvider.jsonToObject(response.body().string(), GetStateCommitteesResponse.class);
final List<EpochCommitteeResponse> data = body.data;
data.forEach(committee -> {
assertThat(committee.index).isEqualTo(ZERO);
assertThat(committee.slot).isEqualTo(UInt64.valueOf(9));
});
assertThat(data.size()).isEqualTo(1);
}
use of tech.pegasys.teku.api.response.v1.beacon.GetStateCommitteesResponse in project teku by ConsenSys.
the class GetStateCommitteesTest method shouldGetCommitteesFromState.
@Test
public void shouldGetCommitteesFromState() throws Exception {
final UInt64 slot = dataStructureUtil.randomUInt64();
final UInt64 epoch = spec.computeEpochAtSlot(dataStructureUtil.randomUInt64());
when(context.pathParamMap()).thenReturn(Map.of("state_id", "head"));
when(context.queryParamMap()).thenReturn(Map.of("index", List.of("1"), "slot", List.of(slot.toString()), "epoch", List.of(epoch.toString())));
when(chainDataProvider.getStateCommittees("head", Optional.of(epoch), Optional.of(UInt64.ONE), Optional.of(slot))).thenReturn(SafeFuture.completedFuture(Optional.of(withMetaData(List.of(epochCommitteeResponse)))));
handler.handle(context);
GetStateCommitteesResponse response = getResponseFromFuture(GetStateCommitteesResponse.class);
assertThat(response.data).isEqualTo(List.of(epochCommitteeResponse));
}
use of tech.pegasys.teku.api.response.v1.beacon.GetStateCommitteesResponse in project teku by ConsenSys.
the class GetStateCommitteesTest method shouldGetCommitteesForSingleIndex.
@Test
public void shouldGetCommitteesForSingleIndex() throws IOException {
final Response response = get("head", Map.of("index", "0"));
assertThat(response.code()).isEqualTo(SC_OK);
final GetStateCommitteesResponse body = jsonProvider.jsonToObject(response.body().string(), GetStateCommitteesResponse.class);
final List<EpochCommitteeResponse> data = body.data;
data.forEach(committee -> assertThat(committee.index).isEqualTo(ZERO));
assertThat(data.size()).isEqualTo(8);
}
Aggregations