Search in sources :

Example 1 with GenesisData

use of tech.pegasys.teku.api.response.v1.beacon.GenesisData 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 2 with GenesisData

use of tech.pegasys.teku.api.response.v1.beacon.GenesisData in project teku by ConsenSys.

the class ChainDataProviderTest method getGenesisData_shouldReturnValueIfStoreAvailable.

@Test
public void getGenesisData_shouldReturnValueIfStoreAvailable() {
    final UInt64 genesisTime = beaconStateInternal.getGenesis_time();
    final Bytes32 genesisValidatorsRoot = beaconStateInternal.getGenesis_validators_root();
    final Bytes4 genesisForkVersion = spec.atEpoch(ZERO).getConfig().getGenesisForkVersion();
    final ChainDataProvider provider = new ChainDataProvider(spec, recentChainData, combinedChainDataClient);
    final GenesisData result = provider.getGenesisData();
    assertThat(result).isEqualTo(new GenesisData(genesisTime, genesisValidatorsRoot, genesisForkVersion));
}
Also used : Bytes4(tech.pegasys.teku.infrastructure.bytes.Bytes4) GenesisData(tech.pegasys.teku.api.response.v1.beacon.GenesisData) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) Bytes32(org.apache.tuweni.bytes.Bytes32) Test(org.junit.jupiter.api.Test)

Example 3 with GenesisData

use of tech.pegasys.teku.api.response.v1.beacon.GenesisData 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)

Aggregations

Test (org.junit.jupiter.api.Test)3 GenesisData (tech.pegasys.teku.api.response.v1.beacon.GenesisData)3 GetGenesisResponse (tech.pegasys.teku.api.response.v1.beacon.GetGenesisResponse)2 UInt64 (tech.pegasys.teku.infrastructure.unsigned.UInt64)2 Optional (java.util.Optional)1 Bytes32 (org.apache.tuweni.bytes.Bytes32)1 AbstractBeaconHandlerTest (tech.pegasys.teku.beaconrestapi.AbstractBeaconHandlerTest)1 Bytes4 (tech.pegasys.teku.infrastructure.bytes.Bytes4)1