Search in sources :

Example 1 with Fork

use of tech.pegasys.teku.api.schema.Fork in project teku by ConsenSys.

the class GetForkIntegrationTest method shouldGetForkChoiceAtEmptyHeadSlot.

@Test
public void shouldGetForkChoiceAtEmptyHeadSlot() throws IOException {
    createBlocksAtSlots(10, 11, 12);
    setCurrentSlot(13);
    final Response response = get("head");
    assertThat(response.code()).isEqualTo(SC_OK);
    final GetStateForkResponse body = jsonProvider.jsonToObject(response.body().string(), GetStateForkResponse.class);
    final Fork data = body.data;
    final Fork expected = new Fork(safeJoin(recentChainData.getBestState().get()).getFork());
    assertThat(expected).isEqualTo(data);
}
Also used : Response(okhttp3.Response) GetStateForkResponse(tech.pegasys.teku.api.response.v1.beacon.GetStateForkResponse) Fork(tech.pegasys.teku.api.schema.Fork) GetStateFork(tech.pegasys.teku.beaconrestapi.handlers.v1.beacon.GetStateFork) GetStateForkResponse(tech.pegasys.teku.api.response.v1.beacon.GetStateForkResponse) Test(org.junit.jupiter.api.Test) AbstractDataBackedRestAPIIntegrationTest(tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest)

Example 2 with Fork

use of tech.pegasys.teku.api.schema.Fork in project web3signer by ConsenSys.

the class Eth2RequestUtils method forkInfo.

public static ForkInfo forkInfo(long epoch) {
    final Fork fork = new Fork(Bytes4.fromHexString("0x00000001"), Bytes4.fromHexString("0x00000001"), UInt64.valueOf(epoch));
    final Bytes32 genesisValidatorsRoot = Bytes32.fromHexString(GENESIS_VALIDATORS_ROOT);
    return new ForkInfo(fork, genesisValidatorsRoot);
}
Also used : Fork(tech.pegasys.teku.api.schema.Fork) ForkInfo(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.ForkInfo) Bytes32(org.apache.tuweni.bytes.Bytes32)

Example 3 with Fork

use of tech.pegasys.teku.api.schema.Fork in project web3signer by ConsenSys.

the class Eth2RequestUtils method forkInfo.

public static ForkInfo forkInfo() {
    final Fork fork = new Fork(Bytes4.fromHexString("0x00000001"), Bytes4.fromHexString("0x00000001"), UInt64.valueOf(1));
    final Bytes32 genesisValidatorsRoot = Bytes32.fromHexString(GENESIS_VALIDATORS_ROOT);
    return new ForkInfo(fork, genesisValidatorsRoot);
}
Also used : Fork(tech.pegasys.teku.api.schema.Fork) ForkInfo(tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.ForkInfo) Bytes32(org.apache.tuweni.bytes.Bytes32)

Example 4 with Fork

use of tech.pegasys.teku.api.schema.Fork in project teku by ConsenSys.

the class ChainDataProviderTest method getStateFork_shouldGetForkAtGenesis.

@Test
public void getStateFork_shouldGetForkAtGenesis() {
    final ChainDataProvider provider = new ChainDataProvider(spec, recentChainData, combinedChainDataClient);
    final Bytes4 bytes4 = Bytes4.fromHexString("0x00000001");
    final SafeFuture<Optional<ObjectAndMetaData<Fork>>> result = provider.getStateFork("genesis");
    assertThatSafeFuture(result).isCompletedWithOptionalContaining(addMetaData(new Fork(bytes4, bytes4, ZERO), ZERO));
}
Also used : Fork(tech.pegasys.teku.api.schema.Fork) Optional(java.util.Optional) Bytes4(tech.pegasys.teku.infrastructure.bytes.Bytes4) Test(org.junit.jupiter.api.Test)

Aggregations

Fork (tech.pegasys.teku.api.schema.Fork)4 Bytes32 (org.apache.tuweni.bytes.Bytes32)2 Test (org.junit.jupiter.api.Test)2 ForkInfo (tech.pegasys.web3signer.core.service.http.handlers.signing.eth2.ForkInfo)2 Optional (java.util.Optional)1 Response (okhttp3.Response)1 GetStateForkResponse (tech.pegasys.teku.api.response.v1.beacon.GetStateForkResponse)1 AbstractDataBackedRestAPIIntegrationTest (tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest)1 GetStateFork (tech.pegasys.teku.beaconrestapi.handlers.v1.beacon.GetStateFork)1 Bytes4 (tech.pegasys.teku.infrastructure.bytes.Bytes4)1