Skip to content

Commit

Permalink
Merge pull request #3 from bomanaps/master
Browse files Browse the repository at this point in the history
API-Update
  • Loading branch information
KatyaRyazantseva authored Sep 3, 2024
2 parents 2795351 + ded6b8c commit bf578ba
Show file tree
Hide file tree
Showing 77 changed files with 488 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ private static EndpointMetadata createEndpointMetadata(final SchemaDefinitionCac
.queryListParam(BLOB_INDICES_PARAMETER)
.response(SC_OK, "Request successful", getResponseType(schemaCache), getSszResponseType())
.withNotFoundResponse()
.withChainDataResponses()
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public GetAllBlocksAtSlot(
.response(SC_OK, "Request successful", getResponseType(schemaDefinitionCache))
.withServiceUnavailableResponse()
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public GetEth1Data(final DataProvider dataProvider, final Eth1DataProvider eth1D
.tags(TAG_TEKU)
.response(SC_OK, "Request successful", ETH1DATA_RESPONSE_TYPE)
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = dataProvider.getChainDataProvider();
this.eth1DataProvider = eth1DataProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public GetEth1VotingSummary(
.tags(TAG_TEKU)
.response(SC_OK, "Request successful", ETH1VOTING_SUMMARY_RESPONSE_TYPE)
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = dataProvider.getChainDataProvider();
this.eth1DataProvider = eth1DataProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public GetFinalizedStateSlotBefore(final ChainDataProvider chainDataProvider) {
.response(SC_OK, "Request successful", UINT64_RESPONSE)
.withServiceUnavailableResponse()
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public GetStateByBlockRoot(final ChainDataProvider chainDataProvider, final Spec
spec.getForkSchedule()
.getSpecMilestoneAtSlot(((BeaconState) beaconState).getSlot())))
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public GetGlobalValidatorInclusion(final ChainDataProvider chainDataProvider) {
.build())
.withNotFoundResponse()
.withServiceUnavailableResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public GetValidatorInclusion(final DataProvider dataProvider) {
.build())
.withNotFoundResponse()
.withServiceUnavailableResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public GetBlindedBlock(
getResponseType(schemaDefinitionCache),
sszResponseType())
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ private static EndpointMetadata createEndpointMetadata(final SchemaDefinitionCac
.queryListParam(BLOB_INDICES_PARAMETER)
.response(SC_OK, "Request successful", getResponseType(schemaCache), getSszResponseType())
.withNotFoundResponse()
.withChainDataResponses()
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public GetBlockAttestations(final ChainDataProvider chainDataProvider, final Spe
.pathParam(PARAMETER_BLOCK_ID)
.response(SC_OK, "Request successful", getResponseType(spec))
.withNotFoundResponse()
.withChainDataResponses()
.deprecated(true)
.build());
this.chainDataProvider = chainDataProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public GetBlockHeader(final ChainDataProvider chainDataProvider) {
.pathParam(PARAMETER_BLOCK_ID)
.response(SC_OK, "Request successful", RESPONSE_TYPE)
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public GetBlockHeaders(final ChainDataProvider chainDataProvider) {
.queryParam(SLOT_PARAMETER.withDescription(SLOT_QUERY_DESCRIPTION))
.queryParam(PARENT_ROOT_PARAMETER)
.response(SC_OK, "Request successful", RESPONSE_TYPE)
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public GetBlockRoot(final ChainDataProvider chainDataProvider) {
.pathParam(PARAMETER_BLOCK_ID)
.response(SC_OK, "Request successful", RESPONSE_TYPE)
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public GetFinalizedBlockRoot(final ChainDataProvider chainDataProvider) {
.pathParam(SLOT_PARAMETER)
.response(SC_OK, "Request successful", RESPONSE_TYPE)
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public GetFinalizedCheckpointState(final ChainDataProvider chainDataProvider, fi
spec.getForkSchedule()
.getSpecMilestoneAtSlot(((BeaconState) beaconState).getSlot())))
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public GetGenesis(final DataProvider dataProvider) {
.tags(TAG_BEACON, TAG_VALIDATOR_REQUIRED)
.response(SC_OK, "Request successful", GET_GENESIS_API_DATA_TYPE)
.response(SC_NOT_FOUND, "Chain genesis info is not yet known")
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public GetStateCommittees(final DataProvider dataProvider) {
.tags(TAG_BEACON)
.response(SC_OK, "Request successful", RESPONSE_TYPE)
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public GetStateFinalityCheckpoints(final DataProvider dataProvider) {
.pathParam(PARAMETER_STATE_ID)
.response(SC_OK, "Request successful", RESPONSE_TYPE)
.withNotFoundResponse()
.withChainDataResponses()
.build(),
chainDataProvider);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public GetStateFork(final DataProvider dataProvider) {
.pathParam(PARAMETER_STATE_ID)
.response(SC_OK, "Request successful", RESPONSE_TYPE)
.withNotFoundResponse()
.withChainDataResponses()
.build(),
chainDataProvider);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ private static EndpointMetadata createMetadata() {
.queryParam(EPOCH_PARAMETER)
.withNotFoundResponse()
.response(SC_OK, "Request successful", responseType)
.withChainDataResponses()
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public GetStateRoot(final DataProvider dataProvider) {
.pathParam(PARAMETER_STATE_ID)
.response(SC_OK, "Request successful", RESPONSE_TYPE)
.withNotFoundResponse()
.withChainDataResponses()
.build(),
chainDataProvider);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public GetStateSyncCommittees(final ChainDataProvider chainDataProvider) {
.queryParam(EPOCH_PARAMETER)
.response(HttpStatusCodes.SC_OK, "Request successful", RESPONSE_TYPE)
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public GetStateValidator(final DataProvider dataProvider) {
.tags(TAG_BEACON, TAG_VALIDATOR_REQUIRED)
.response(SC_OK, "Request successful", RESPONSE_TYPE)
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = provider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public GetStateValidatorBalances(final DataProvider dataProvider) {
.queryListParam(ID_PARAMETER)
.response(SC_OK, "Request successful", RESPONSE_TYPE)
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public GetStateValidators(final DataProvider dataProvider) {
.tags(TAG_BEACON)
.response(SC_OK, "Request successful", STATE_VALIDATORS_RESPONSE_TYPE)
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = provider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public PostStateValidatorBalances(final DataProvider dataProvider) {
.requestBodyType(DeserializableTypeDefinition.listOf(STRING_TYPE))
.response(SC_OK, "Request successful", GetStateValidatorBalances.RESPONSE_TYPE)
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public PostStateValidators(final DataProvider dataProvider) {
.tags(TAG_BEACON)
.response(SC_OK, "Request successful", STATE_VALIDATORS_RESPONSE_TYPE)
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = provider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public GetLightClientBootstrap(
.withNotFoundResponse()
.withNotAcceptedResponse()
.withNotImplementedResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ protected GetExpectedWithdrawals(
.response(SC_OK, "Request successful", getResponseType(schemaDefinitionCache))
.withNotFoundResponse()
.withNotImplementedResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public GetState(
beaconState ->
spec.getForkSchedule().getSpecMilestoneAtSlot(beaconState.getSlot())))
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public GetEvents(
.tags(TAG_EVENTS, TAG_VALIDATOR_REQUIRED)
.queryParam(TOPICS_PARAMETER)
.response(SC_OK, "Request successful", new EventStreamResponseContentTypeDefinition())
.withChainDataResponses()
.build());
eventSubscriptionManager =
new EventSubscriptionManager(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public GetAttestationRewards(final ChainDataProvider chainDataProvider) {
.withNotImplementedResponse()
.withNotFoundResponse()
.withInternalErrorResponse()
.withChainDataResponses()
.build());

this.chainDataProvider = chainDataProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public GetBlockRewards(final ChainDataProvider chainDataProvider) {
.response(SC_OK, "Request successful", RESPONSE_TYPE)
.withNotFoundResponse()
.withInternalErrorResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public GetSyncCommitteeRewards(final ChainDataProvider chainDataProvider) {
.response(SC_OK, "Request successful", RESPONSE_TYPE)
.withNotFoundResponse()
.withInternalErrorResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public PostValidatorLiveness(
.requestBodyType(DeserializableTypeDefinition.listOf(UINT64_TYPE, 1))
.response(SC_OK, "Successful Response", RESPONSE_TYPE)
.withServiceUnavailableResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
this.nodeDataProvider = nodeDataProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public GetBlock(
getResponseType(schemaDefinitionCache),
sszResponseType())
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public GetBlockAttestationsV2(
.pathParam(PARAMETER_BLOCK_ID)
.response(SC_OK, "Request successful", getResponseType(schemaDefinitionCache))
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public GetChainHeadsV2(final ChainDataProvider chainDataProvider) {
.description("Retrieves all possible chain heads (leaves of fork choice tree).")
.tags(TAG_DEBUG)
.response(SC_OK, "Success", responseType(CHAIN_HEAD_TYPE_V2))
.withChainDataResponses()
.build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public GetState(
getResponseType(schemaDefinitionCache),
sszResponseType())
.withNotFoundResponse()
.withChainDataResponses()
.build());
this.chainDataProvider = chainDataProvider;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_BAD_REQUEST;
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_INTERNAL_SERVER_ERROR;
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_NOT_FOUND;
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_NO_CONTENT;
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_OK;
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_SERVICE_UNAVAILABLE;
import static tech.pegasys.teku.infrastructure.http.RestApiConstants.SLOT;
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.getResponseStringFromMetadata;
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.verifyMetadataEmptyResponse;
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.verifyMetadataErrorResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand Down Expand Up @@ -94,4 +97,14 @@ void metadata_shouldHandle200() throws IOException {
UTF_8);
assertThat(data).isEqualTo(expected);
}

@Test
void metadata_shouldHandle204() {
verifyMetadataEmptyResponse(handler, SC_NO_CONTENT);
}

@Test
void metadata_shouldHandle503() throws JsonProcessingException {
verifyMetadataErrorResponse(handler, SC_SERVICE_UNAVAILABLE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_BAD_REQUEST;
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_INTERNAL_SERVER_ERROR;
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_NOT_FOUND;
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_NO_CONTENT;
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_OK;
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_SERVICE_UNAVAILABLE;
import static tech.pegasys.teku.infrastructure.http.RestApiConstants.SLOT;
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.getResponseStringFromMetadata;
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.verifyMetadataEmptyResponse;
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.verifyMetadataErrorResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand Down Expand Up @@ -93,4 +95,9 @@ void metadata_shouldHandle200() throws IOException {
Resources.getResource(GetAllBlocksAtSlotTest.class, "getAllBlocksAtSlot.json"), UTF_8);
assertThat(data).isEqualTo(expected);
}

@Test
void metadata_shouldHandle204() {
verifyMetadataEmptyResponse(handler, SC_NO_CONTENT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_BAD_REQUEST;
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_INTERNAL_SERVER_ERROR;
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_NOT_FOUND;
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_NO_CONTENT;
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_OK;
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_SERVICE_UNAVAILABLE;
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.getResponseStringFromMetadata;
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.verifyMetadataEmptyResponse;
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.verifyMetadataErrorResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
Expand Down Expand Up @@ -98,4 +101,14 @@ void metadata_shouldHandle200() throws JsonProcessingException {
.isEqualTo(
"{\"data\":{\"deposit_root\":\"0xd543a5c171f43007ec7a6871885a3faeb3fd8c4f5a810097508ffd301459aa22\",\"deposit_count\":\"20\",\"block_hash\":\"0xaf01b1c1315d727d01f5991ae1481614a7f78e2beeefae22f48c76a05f973b0d\"}}");
}

@Test
void metadata_shouldHandle204() {
verifyMetadataEmptyResponse(handler, SC_NO_CONTENT);
}

@Test
void metadata_shouldHandle503() throws JsonProcessingException {
verifyMetadataErrorResponse(handler, SC_SERVICE_UNAVAILABLE);
}
}
Loading

0 comments on commit bf578ba

Please sign in to comment.