Search in sources :

Example 1 with GetGenesisResponse

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;
}
Also used : GetGenesisResponse(tech.pegasys.teku.api.response.v1.beacon.GetGenesisResponse)

Example 2 with GetGenesisResponse

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);
}
Also used : GenesisData(tech.pegasys.teku.api.response.v1.beacon.GenesisData) GetGenesisResponse(tech.pegasys.teku.api.response.v1.beacon.GetGenesisResponse) Test(org.junit.jupiter.api.Test) AbstractBeaconHandlerTest(tech.pegasys.teku.beaconrestapi.AbstractBeaconHandlerTest)

Example 3 with GetGenesisResponse

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);
}
Also used : Optional(java.util.Optional) GenesisData(tech.pegasys.teku.api.response.v1.beacon.GenesisData) GetGenesisResponse(tech.pegasys.teku.api.response.v1.beacon.GetGenesisResponse) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) Test(org.junit.jupiter.api.Test)

Example 4 with GetGenesisResponse

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);
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) GetGenesisResponse(tech.pegasys.teku.api.response.v1.beacon.GetGenesisResponse) Test(org.junit.jupiter.api.Test)

Aggregations

GetGenesisResponse (tech.pegasys.teku.api.response.v1.beacon.GetGenesisResponse)4 Test (org.junit.jupiter.api.Test)3 GenesisData (tech.pegasys.teku.api.response.v1.beacon.GenesisData)2 Optional (java.util.Optional)1 MockResponse (okhttp3.mockwebserver.MockResponse)1 AbstractBeaconHandlerTest (tech.pegasys.teku.beaconrestapi.AbstractBeaconHandlerTest)1 UInt64 (tech.pegasys.teku.infrastructure.unsigned.UInt64)1