Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.io.IOException;
import java.util.List;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.api.response.v1.EventType;
import tech.pegasys.teku.api.response.EventType;
import tech.pegasys.teku.bls.BLSKeyPair;
import tech.pegasys.teku.ethereum.execution.types.Eth1Address;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import java.io.IOException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.api.response.v1.EventType;
import tech.pegasys.teku.api.response.EventType;
import tech.pegasys.teku.infrastructure.time.SystemTimeProvider;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.test.acceptance.dsl.AcceptanceTestBase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import org.testcontainers.containers.Network;
import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
import tech.pegasys.teku.api.migrated.ValidatorLivenessAtEpoch;
import tech.pegasys.teku.api.response.v1.EventType;
import tech.pegasys.teku.api.response.EventType;
import tech.pegasys.teku.bls.BLS;
import tech.pegasys.teku.bls.BLSKeyPair;
import tech.pegasys.teku.bls.BLSSecretKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.testcontainers.containers.Network;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import org.testcontainers.utility.MountableFile;
import tech.pegasys.teku.api.response.v1.EventType;
import tech.pegasys.teku.api.response.EventType;

public abstract class TekuNode extends Node {
public static final int VALIDATOR_API_PORT = 9052;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
import tech.pegasys.teku.api.NetworkDataProvider;
import tech.pegasys.teku.api.NodeDataProvider;
import tech.pegasys.teku.api.migrated.ValidatorLivenessAtEpoch;
import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus;
import tech.pegasys.teku.api.response.ValidatorStatus;
import tech.pegasys.teku.beacon.sync.events.SyncState;
import tech.pegasys.teku.beacon.sync.events.SyncStateProvider;
import tech.pegasys.teku.bls.BLSPublicKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
import org.apache.tuweni.bytes.Bytes32;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.api.schema.Eth1Data;
import tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest;
import tech.pegasys.teku.beaconrestapi.handlers.tekuv1.beacon.GetEth1DataCache;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.datastructures.blocks.Eth1Data;
import tech.pegasys.teku.spec.util.DataStructureUtil;

public class GetEth1DataCacheIntegrationTest extends AbstractDataBackedRestAPIIntegrationTest {
Expand All @@ -45,15 +45,11 @@ public void setup() {

@Test
public void shouldReturnAllEth1BlocksFromCache() throws IOException {
List<tech.pegasys.teku.spec.datastructures.blocks.Eth1Data> eth1DataCacheList =
new ArrayList<>();
final List<Eth1Data> eth1DataCacheList = new ArrayList<>();
for (int i = 0; i < 5; i++) {
eth1DataCacheList.add(dataStructureUtil.randomEth1Data());
}
List<Eth1Data> eth1DataCacheBlocks = new ArrayList<>();
eth1DataCacheList.stream()
.map(Eth1Data::new)
.forEach(eth1Block -> eth1DataCacheBlocks.add(eth1Block));
final List<Eth1Data> eth1DataCacheBlocks = new ArrayList<>(eth1DataCacheList);
when(eth1DataProvider.getEth1CachedBlocks()).thenReturn(eth1DataCacheList);
final Response response = get();
assertThat(response.code()).isEqualTo(SC_OK);
Expand All @@ -63,11 +59,11 @@ public void shouldReturnAllEth1BlocksFromCache() throws IOException {
final JsonNode block = data.get(i);
final Eth1Data eth1Data = eth1DataCacheBlocks.get(i);
assertThat(Bytes32.fromHexString(block.get("deposit_root").asText()))
.isEqualTo(eth1Data.deposit_root);
.isEqualTo(eth1Data.getDepositRoot());
assertThat(UInt64.valueOf(block.get("deposit_count").asText()))
.isEqualTo(eth1Data.deposit_count);
.isEqualTo(eth1Data.getDepositCount());
assertThat(Bytes32.fromHexString(block.get("block_hash").asText()))
.isEqualTo(eth1Data.block_hash);
.isEqualTo(eth1Data.getBlockHash());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import okhttp3.Response;
import org.apache.tuweni.bytes.Bytes;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.api.schema.Version;
import tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest;
import tech.pegasys.teku.beaconrestapi.handlers.v1.beacon.GetBlindedBlock;
import tech.pegasys.teku.ethereum.json.types.SharedApiTypes;
Expand All @@ -46,7 +45,8 @@ public void shouldGetBlindedPhase0Block() throws IOException {
assertThat(result.isBlinded()).isFalse();
assertThat(result).isEqualTo(created.get(0).getBlock());
assertThat(result.hashTreeRoot()).isEqualTo(created.get(0).getBlock().hashTreeRoot());
assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.phase0.name());
assertThat(response.header(HEADER_CONSENSUS_VERSION))
.isEqualTo(SpecMilestone.PHASE0.lowerCaseName());
}

@Test
Expand All @@ -59,7 +59,8 @@ public void shouldGetBlindedBellatrixBlock() throws IOException {

assertThat(result.isBlinded()).isTrue();
assertThat(result.hashTreeRoot()).isEqualTo(created.get(0).getBlock().hashTreeRoot());
assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.bellatrix.name());
assertThat(response.header(HEADER_CONSENSUS_VERSION))
.isEqualTo(SpecMilestone.BELLATRIX.lowerCaseName());
}

@Test
Expand All @@ -75,7 +76,8 @@ public void shouldGetBellatrixBlockAsSsz() throws IOException {
.sszDeserialize(Bytes.of(response.body().bytes()));
assertThat(result.isBlinded()).isTrue();
assertThat(result.hashTreeRoot()).isEqualTo(created.get(0).getBlock().hashTreeRoot());
assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.bellatrix.name());
assertThat(response.header(HEADER_CONSENSUS_VERSION))
.isEqualTo(SpecMilestone.BELLATRIX.lowerCaseName());
}

public Response get(final String blockIdString, final String contentType) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.apache.tuweni.bytes.Bytes;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.api.schema.Version;
import tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest;
import tech.pegasys.teku.beaconrestapi.handlers.v1.beacon.GetFinalizedCheckpointState;
import tech.pegasys.teku.infrastructure.http.ContentTypes;
Expand All @@ -43,7 +42,8 @@ public void shouldGetBellatrixStateAsSsz()
final Response response =
getResponse(GetFinalizedCheckpointState.ROUTE, ContentTypes.OCTET_STREAM);
assertThat(response.code()).isEqualTo(SC_OK);
assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.bellatrix.name());
assertThat(response.header(HEADER_CONSENSUS_VERSION))
.isEqualTo(SpecMilestone.BELLATRIX.lowerCaseName());
final Bytes actualResponse = Bytes.wrap(response.body().bytes());
assertThat(actualResponse)
.isEqualTo(combinedChainDataClient.getBestState().get().get().sszSerialize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.List;
import okhttp3.Response;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.api.schema.Version;
import tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest;
import tech.pegasys.teku.beaconrestapi.handlers.v1.beacon.GetStatePendingDeposits;
import tech.pegasys.teku.infrastructure.json.JsonTestUtil;
Expand Down Expand Up @@ -50,7 +49,8 @@ public void shouldGetElectraDepositsJson() throws Exception {
assertThat(node.get("data").get(1).get("slot").asInt()).isEqualTo(10);
assertThat(node.get("data").get(1).get("pubkey").asText())
.isEqualTo(stateElectra.getPendingDeposits().get(1).getPublicKey().toHexString());
assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.electra.name());
assertThat(response.header(HEADER_CONSENSUS_VERSION))
.isEqualTo(SpecMilestone.ELECTRA.lowerCaseName());
}

public Response get(final String stateId) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.io.IOException;
import okhttp3.Response;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.api.schema.Version;
import tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest;
import tech.pegasys.teku.beaconrestapi.handlers.v1.beacon.GetStatePendingPartialWithdrawals;
import tech.pegasys.teku.infrastructure.json.JsonTestUtil;
Expand All @@ -40,7 +39,8 @@ public void shouldGetElectraDepositsJson() throws Exception {
assertThat(node.get("execution_optimistic").asBoolean()).isFalse();
assertThat(node.get("finalized").asBoolean()).isFalse();
assertThat(node.get("data").size()).isEqualTo(0);
assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.electra.name());
assertThat(response.header(HEADER_CONSENSUS_VERSION))
.isEqualTo(SpecMilestone.ELECTRA.lowerCaseName());
}

public Response get(final String stateId) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import tech.pegasys.teku.api.response.v1.beacon.ValidatorStatus;
import tech.pegasys.teku.api.response.ValidatorStatus;
import tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest;
import tech.pegasys.teku.beaconrestapi.handlers.v1.validator.PostRegisterValidator;
import tech.pegasys.teku.bls.BLSPublicKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.zip.GZIPInputStream;
import okhttp3.Response;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.api.schema.Version;
import tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest;
import tech.pegasys.teku.beaconrestapi.handlers.v2.beacon.GetBlock;
import tech.pegasys.teku.infrastructure.http.ContentTypes;
Expand All @@ -46,12 +45,13 @@ public void shouldGetBlock() throws IOException {
final Response response = get("head");
final JsonNode body = OBJECT_MAPPER.readTree(response.body().string());

assertThat(body.get("version").asText()).isEqualTo(Version.phase0.name());
assertThat(body.get("version").asText()).isEqualTo(SpecMilestone.PHASE0.lowerCaseName());
assertThat(body.get("data").get("message").get("parent_root").asText())
.isEqualTo(created.get(0).getBlock().getMessage().getParentRoot().toHexString());
assertThat(body.get("data").get("message").get("state_root").asText())
.isEqualTo(created.get(0).getBlock().getMessage().getStateRoot().toHexString());
assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.phase0.name());
assertThat(response.header(HEADER_CONSENSUS_VERSION))
.isEqualTo(SpecMilestone.PHASE0.lowerCaseName());

// this is the most practical way to compare the block to that created, but its secondary to
// comparing state root and parent root.
Expand All @@ -67,12 +67,13 @@ public void shouldGetAltairBlock() throws IOException {
final Response response = get("head");
final JsonNode body = OBJECT_MAPPER.readTree(response.body().string());

assertThat(body.get("version").asText()).isEqualTo(Version.altair.name());
assertThat(body.get("version").asText()).isEqualTo(SpecMilestone.ALTAIR.lowerCaseName());
assertThat(body.get("data").get("message").get("parent_root").asText())
.isEqualTo(created.get(0).getBlock().getMessage().getParentRoot().toHexString());
assertThat(body.get("data").get("message").get("state_root").asText())
.isEqualTo(created.get(0).getBlock().getMessage().getStateRoot().toHexString());
assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.altair.name());
assertThat(response.header(HEADER_CONSENSUS_VERSION))
.isEqualTo(SpecMilestone.ALTAIR.lowerCaseName());

// this is the most practical way to compare the block to that created, but its secondary to
// comparing state root and parent root.
Expand All @@ -97,7 +98,8 @@ public void shouldGetAltairBlockAsSsz() throws IOException {
createBlocksAtSlots(10);
final Response response = get("head", OCTET_STREAM);
assertThat(response.code()).isEqualTo(SC_OK);
assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.altair.name());
assertThat(response.header(HEADER_CONSENSUS_VERSION))
.isEqualTo(SpecMilestone.ALTAIR.lowerCaseName());
}

@Test
Expand All @@ -106,7 +108,8 @@ public void shouldGetAltairBlockAsGzip() throws IOException {
createBlocksAtSlots(10);
final Response response = getGzip("head", ContentTypes.JSON);
assertThat(response.code()).isEqualTo(SC_OK);
assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.altair.name());
assertThat(response.header(HEADER_CONSENSUS_VERSION))
.isEqualTo(SpecMilestone.ALTAIR.lowerCaseName());
assertThat(response.header(HEADER_CONTENT_ENCODING)).isEqualTo("gzip");

// Decompress response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.function.Function;
import okhttp3.Response;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.api.schema.Version;
import tech.pegasys.teku.beaconrestapi.AbstractDataBackedRestAPIIntegrationTest;
import tech.pegasys.teku.beaconrestapi.handlers.v2.debug.GetState;
import tech.pegasys.teku.infrastructure.http.ContentTypes;
Expand Down Expand Up @@ -53,7 +52,8 @@ public void shouldGetPhase0StateAsJson() throws IOException {
assertThat(stateResponse).isNotNull();
assertThat(stateResponse.getVersion()).isEqualTo(SpecMilestone.PHASE0);
assertThat(stateResponse.getData()).isInstanceOf(BeaconStatePhase0.class);
assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.phase0.name());
assertThat(response.header(HEADER_CONSENSUS_VERSION))
.isEqualTo(SpecMilestone.PHASE0.lowerCaseName());
}

@Test
Expand All @@ -71,15 +71,17 @@ public void shouldGetAltairStateAsJson() throws IOException {
assertThat(stateResponse).isNotNull();
assertThat(stateResponse.getVersion()).isEqualTo(SpecMilestone.ALTAIR);
assertThat(stateResponse.getData()).isInstanceOf(BeaconStateAltair.class);
assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.altair.name());
assertThat(response.header(HEADER_CONSENSUS_VERSION))
.isEqualTo(SpecMilestone.ALTAIR.lowerCaseName());
}

@Test
public void shouldGetAltairStateAsSsz() throws IOException {
startRestAPIAtGenesis(SpecMilestone.ALTAIR);
final Response response = get("head", OCTET_STREAM);
assertThat(response.code()).isEqualTo(SC_OK);
assertThat(response.header(HEADER_CONSENSUS_VERSION)).isEqualTo(Version.altair.name());
assertThat(response.header(HEADER_CONSENSUS_VERSION))
.isEqualTo(SpecMilestone.ALTAIR.lowerCaseName());
}

public Response get(final String stateIdIdString, final String contentType) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
import java.util.function.Function;
import java.util.stream.Collectors;
import org.apache.tuweni.bytes.Bytes32;
import tech.pegasys.teku.api.response.v1.EventType;
import tech.pegasys.teku.api.response.EventType;
import tech.pegasys.teku.bls.BLSSignature;
import tech.pegasys.teku.ethereum.json.types.beacon.StatusParameter;
import tech.pegasys.teku.infrastructure.http.RestApiConstants;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.Optional;
import tech.pegasys.teku.api.ChainDataProvider;
import tech.pegasys.teku.api.DataProvider;
import tech.pegasys.teku.api.schema.Version;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.json.types.SerializableTypeDefinition;
import tech.pegasys.teku.infrastructure.restapi.endpoints.AsyncApiResponse;
Expand Down Expand Up @@ -87,7 +86,7 @@ public void handleRequest(final RestApiRequest request) throws JsonProcessingExc
blockAndMetaData -> {
request.header(
HEADER_CONSENSUS_VERSION,
Version.fromMilestone(blockAndMetaData.getMilestone()).name());
blockAndMetaData.getMilestone().lowerCaseName());
return AsyncApiResponse.respondOk(blockAndMetaData);
})
.orElseGet(AsyncApiResponse::respondNotFound)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.Optional;
import tech.pegasys.teku.api.ChainDataProvider;
import tech.pegasys.teku.api.DataProvider;
import tech.pegasys.teku.api.schema.Version;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.json.types.DeserializableTypeDefinition;
import tech.pegasys.teku.infrastructure.json.types.SerializableTypeDefinition;
Expand Down Expand Up @@ -100,7 +99,7 @@ public void handleRequest(final RestApiRequest request) throws JsonProcessingExc
blobSidecarsAndMetaData -> {
request.header(
HEADER_CONSENSUS_VERSION,
Version.fromMilestone(blobSidecarsAndMetaData.getMilestone()).name());
blobSidecarsAndMetaData.getMilestone().lowerCaseName());
return AsyncApiResponse.respondOk(blobSidecarsAndMetaData);
})
.orElse(AsyncApiResponse.respondNotFound())));
Expand Down
Loading