use of tech.pegasys.teku.api.response.v1.beacon.GetGenesisResponse in project teku by ConsenSys.
the class TekuNode method fetchGenesisTime.
private UInt64 fetchGenesisTime() throws IOException {
String genesisTime = httpClient.get(getRestApiUrl(), "/eth/v1/beacon/genesis");
final GetGenesisResponse response = jsonProvider.jsonToObject(genesisTime, GetGenesisResponse.class);
return response.data.genesisTime;
}
use of tech.pegasys.teku.api.response.v1.beacon.GetGenesisResponse in project teku by ConsenSys.
the class GetGenesisTest method shouldReturnGenesisInformation.
@Test
public void shouldReturnGenesisInformation() throws Exception {
final GetGenesis handler = new GetGenesis(chainDataProvider, jsonProvider);
final GenesisData expectedGenesisData = new GenesisData(dataStructureUtil.randomUInt64(), dataStructureUtil.randomBytes32(), dataStructureUtil.randomBytes4());
when(chainDataProvider.isStoreAvailable()).thenReturn(true);
when(chainDataProvider.getGenesisData()).thenReturn(expectedGenesisData);
handler.handle(context);
final GetGenesisResponse response = getResponseObject(GetGenesisResponse.class);
assertThat(response.data).isEqualTo(expectedGenesisData);
}
use of tech.pegasys.teku.api.response.v1.beacon.GetGenesisResponse in project teku by ConsenSys.
the class RemoteValidatorApiHandlerTest method getGenesisTime_WhenPresent_ReturnsValue.
@Test
public void getGenesisTime_WhenPresent_ReturnsValue() {
final UInt64 genesisTime = dataStructureUtil.randomUInt64();
when(apiClient.getGenesis()).thenReturn(Optional.of(new GetGenesisResponse(new GenesisData(genesisTime, dataStructureUtil.randomBytes32(), dataStructureUtil.randomBytes4()))));
SafeFuture<Optional<tech.pegasys.teku.spec.datastructures.genesis.GenesisData>> future = apiHandler.getGenesisData();
assertThat(unwrapToValue(future).getGenesisTime()).isEqualTo(genesisTime);
}
use of tech.pegasys.teku.api.response.v1.beacon.GetGenesisResponse in project teku by ConsenSys.
the class OkHttpValidatorRestApiClientTest method getGenesis_WhenSuccess_ReturnsGenesisResponse.
@Test
public void getGenesis_WhenSuccess_ReturnsGenesisResponse() {
final GetGenesisResponse getGenesisResponse = schemaObjects.getGenesisResponse();
mockWebServer.enqueue(new MockResponse().setResponseCode(SC_OK).setBody(asJson(getGenesisResponse)));
Optional<GetGenesisResponse> genesis = apiClient.getGenesis();
assertThat(genesis).isPresent();
assertThat(genesis.get()).usingRecursiveComparison().isEqualTo(getGenesisResponse);
}
Aggregations