@Test public void shouldReturnServerErrorWhenFutureHasUnmappedException() throws Exception { final SignedAggregateAndProof signedAggregateAndProof = dataStructureUtil.randomSignedAggregateAndProof(); final tech.pegasys.teku.api.schema.SignedAggregateAndProof schemaSignedAggregateAndProof = new tech.pegasys.teku.api.schema.SignedAggregateAndProof(signedAggregateAndProof); when(context.body()).thenReturn(jsonProvider.objectToJSON(schemaSignedAggregateAndProof)); doThrow(new RuntimeException()).when(provider).sendAggregateAndProof(any()); handler.handle(context); verify(context).status(SC_INTERNAL_SERVER_ERROR); }
@OpenApi( path = ROUTE, method = HttpMethod.POST, summary = "Verifies given aggregate and proof and publishes it on appropriate gossipsub topic.", tags = {TAG_VALIDATOR}, requestBody = @OpenApiRequestBody(content = {@OpenApiContent(from = SignedAggregateAndProof.class)}), description = "Aggregates all attestations matching given attestation data root and slot.", responses = { @OpenApiResponse(status = RES_OK, description = "Successfully processed attestation."), @OpenApiResponse(status = RES_BAD_REQUEST, description = "Invalid parameter supplied."), @OpenApiResponse(status = RES_INTERNAL_ERROR, description = "Beacon node internal error.") }) @Override public void handle(Context ctx) throws Exception { try { final SignedAggregateAndProof signedAggregateAndProof = jsonProvider.jsonToObject(ctx.body(), SignedAggregateAndProof.class); provider.sendAggregateAndProof(signedAggregateAndProof); ctx.status(SC_OK); } catch (final JsonMappingException e) { ctx.result(jsonProvider.objectToJSON(new BadRequest(e.getMessage()))); ctx.status(SC_BAD_REQUEST); } catch (Exception e) { ctx.status(SC_INTERNAL_SERVER_ERROR); } }
PostAggregateAndProof implements Handler { @OpenApi( path = ROUTE, method = HttpMethod.POST, summary = "Verifies given aggregate and proof and publishes it on appropriate gossipsub topic.", tags = {TAG_VALIDATOR}, requestBody = @OpenApiRequestBody(content = {@OpenApiContent(from = SignedAggregateAndProof.class)}), description = "Aggregates all attestations matching given attestation data root and slot.", responses = { @OpenApiResponse(status = RES_OK, description = "Successfully processed attestation."), @OpenApiResponse(status = RES_BAD_REQUEST, description = "Invalid parameter supplied."), @OpenApiResponse(status = RES_INTERNAL_ERROR, description = "Beacon node internal error.") }) @Override public void handle(Context ctx) throws Exception { try { final SignedAggregateAndProof signedAggregateAndProof = jsonProvider.jsonToObject(ctx.body(), SignedAggregateAndProof.class); provider.sendAggregateAndProof(signedAggregateAndProof); ctx.status(SC_OK); } catch (final JsonMappingException e) { ctx.result(jsonProvider.objectToJSON(new BadRequest(e.getMessage()))); ctx.status(SC_BAD_REQUEST); } catch (Exception e) { ctx.status(SC_INTERNAL_SERVER_ERROR); } } }
PostAggregateAndProof implements Handler { @OpenApi( path = ROUTE, method = HttpMethod.POST, summary = "Verifies given aggregate and proof and publishes it on appropriate gossipsub topic.", tags = {TAG_VALIDATOR}, requestBody = @OpenApiRequestBody(content = {@OpenApiContent(from = SignedAggregateAndProof.class)}), description = "Aggregates all attestations matching given attestation data root and slot.", responses = { @OpenApiResponse(status = RES_OK, description = "Successfully processed attestation."), @OpenApiResponse(status = RES_BAD_REQUEST, description = "Invalid parameter supplied."), @OpenApiResponse(status = RES_INTERNAL_ERROR, description = "Beacon node internal error.") }) @Override public void handle(Context ctx) throws Exception { try { final SignedAggregateAndProof signedAggregateAndProof = jsonProvider.jsonToObject(ctx.body(), SignedAggregateAndProof.class); provider.sendAggregateAndProof(signedAggregateAndProof); ctx.status(SC_OK); } catch (final JsonMappingException e) { ctx.result(jsonProvider.objectToJSON(new BadRequest(e.getMessage()))); ctx.status(SC_BAD_REQUEST); } catch (Exception e) { ctx.status(SC_INTERNAL_SERVER_ERROR); } } PostAggregateAndProof(
      final ValidatorDataProvider provider, final JsonProvider jsonProvider); }
PostAggregateAndProof implements Handler { @OpenApi( path = ROUTE, method = HttpMethod.POST, summary = "Verifies given aggregate and proof and publishes it on appropriate gossipsub topic.", tags = {TAG_VALIDATOR}, requestBody = @OpenApiRequestBody(content = {@OpenApiContent(from = SignedAggregateAndProof.class)}), description = "Aggregates all attestations matching given attestation data root and slot.", responses = { @OpenApiResponse(status = RES_OK, description = "Successfully processed attestation."), @OpenApiResponse(status = RES_BAD_REQUEST, description = "Invalid parameter supplied."), @OpenApiResponse(status = RES_INTERNAL_ERROR, description = "Beacon node internal error.") }) @Override public void handle(Context ctx) throws Exception { try { final SignedAggregateAndProof signedAggregateAndProof = jsonProvider.jsonToObject(ctx.body(), SignedAggregateAndProof.class); provider.sendAggregateAndProof(signedAggregateAndProof); ctx.status(SC_OK); } catch (final JsonMappingException e) { ctx.result(jsonProvider.objectToJSON(new BadRequest(e.getMessage()))); ctx.status(SC_BAD_REQUEST); } catch (Exception e) { ctx.status(SC_INTERNAL_SERVER_ERROR); } } PostAggregateAndProof(
      final ValidatorDataProvider provider, final JsonProvider jsonProvider); @OpenApi( path = ROUTE, method = HttpMethod.POST, summary = "Verifies given aggregate and proof and publishes it on appropriate gossipsub topic.", tags = {TAG_VALIDATOR}, requestBody = @OpenApiRequestBody(content = {@OpenApiContent(from = SignedAggregateAndProof.class)}), description = "Aggregates all attestations matching given attestation data root and slot.", responses = { @OpenApiResponse(status = RES_OK, description = "Successfully processed attestation."), @OpenApiResponse(status = RES_BAD_REQUEST, description = "Invalid parameter supplied."), @OpenApiResponse(status = RES_INTERNAL_ERROR, description = "Beacon node internal error.") }) @Override void handle(Context ctx); }
PostAggregateAndProof implements Handler { @OpenApi( path = ROUTE, method = HttpMethod.POST, summary = "Verifies given aggregate and proof and publishes it on appropriate gossipsub topic.", tags = {TAG_VALIDATOR}, requestBody = @OpenApiRequestBody(content = {@OpenApiContent(from = SignedAggregateAndProof.class)}), description = "Aggregates all attestations matching given attestation data root and slot.", responses = { @OpenApiResponse(status = RES_OK, description = "Successfully processed attestation."), @OpenApiResponse(status = RES_BAD_REQUEST, description = "Invalid parameter supplied."), @OpenApiResponse(status = RES_INTERNAL_ERROR, description = "Beacon node internal error.") }) @Override public void handle(Context ctx) throws Exception { try { final SignedAggregateAndProof signedAggregateAndProof = jsonProvider.jsonToObject(ctx.body(), SignedAggregateAndProof.class); provider.sendAggregateAndProof(signedAggregateAndProof); ctx.status(SC_OK); } catch (final JsonMappingException e) { ctx.result(jsonProvider.objectToJSON(new BadRequest(e.getMessage()))); ctx.status(SC_BAD_REQUEST); } catch (Exception e) { ctx.status(SC_INTERNAL_SERVER_ERROR); } } PostAggregateAndProof(
      final ValidatorDataProvider provider, final JsonProvider jsonProvider); @OpenApi( path = ROUTE, method = HttpMethod.POST, summary = "Verifies given aggregate and proof and publishes it on appropriate gossipsub topic.", tags = {TAG_VALIDATOR}, requestBody = @OpenApiRequestBody(content = {@OpenApiContent(from = SignedAggregateAndProof.class)}), description = "Aggregates all attestations matching given attestation data root and slot.", responses = { @OpenApiResponse(status = RES_OK, description = "Successfully processed attestation."), @OpenApiResponse(status = RES_BAD_REQUEST, description = "Invalid parameter supplied."), @OpenApiResponse(status = RES_INTERNAL_ERROR, description = "Beacon node internal error.") }) @Override void handle(Context ctx); static final String ROUTE; }