use of tech.pegasys.teku.api.schema.SignedAggregateAndProof in project teku by ConsenSys.
the class OkHttpValidatorRestApiClientTest method sendAggregateAndProofs_MakesExpectedRequest.
@Test
public void sendAggregateAndProofs_MakesExpectedRequest() throws Exception {
final SignedAggregateAndProof signedAggregateAndProof = schemaObjects.signedAggregateAndProof();
mockWebServer.enqueue(new MockResponse().setResponseCode(SC_OK));
apiClient.sendAggregateAndProofs(List.of(signedAggregateAndProof));
RecordedRequest request = mockWebServer.takeRequest();
assertThat(request.getMethod()).isEqualTo("POST");
assertThat(request.getPath()).contains(ValidatorApiMethod.SEND_SIGNED_AGGREGATE_AND_PROOF.getPath(emptyMap()));
assertThat(request.getBody().readString(StandardCharsets.UTF_8)).isEqualTo(asJson(List.of(signedAggregateAndProof)));
}
use of tech.pegasys.teku.api.schema.SignedAggregateAndProof in project teku by ConsenSys.
the class OkHttpValidatorRestApiClientTest method sendAggregateAndProofs_WhenBadParameters_ReturnsErrorResponse.
@Test
public void sendAggregateAndProofs_WhenBadParameters_ReturnsErrorResponse() {
final SignedAggregateAndProof signedAggregateAndProof = schemaObjects.signedAggregateAndProof();
final PostDataFailureResponse response = new PostDataFailureResponse(SC_BAD_REQUEST, "Computer said no", List.of(new PostDataFailure(UInt64.ZERO, "Bad")));
mockWebServer.enqueue(new MockResponse().setResponseCode(SC_BAD_REQUEST).setBody(asJson(response)));
assertThat(apiClient.sendAggregateAndProofs(List.of(signedAggregateAndProof))).isPresent().get().usingRecursiveComparison().isEqualTo(response);
}
use of tech.pegasys.teku.api.schema.SignedAggregateAndProof in project teku by ConsenSys.
the class OkHttpValidatorRestApiClientTest method sendAggregateAndProofs_WhenServerError_ThrowsRuntimeException.
@Test
public void sendAggregateAndProofs_WhenServerError_ThrowsRuntimeException() {
final SignedAggregateAndProof signedAggregateAndProof = schemaObjects.signedAggregateAndProof();
mockWebServer.enqueue(new MockResponse().setResponseCode(SC_INTERNAL_SERVER_ERROR));
assertThatThrownBy(() -> apiClient.sendAggregateAndProofs(List.of(signedAggregateAndProof))).isInstanceOf(RuntimeException.class).hasMessageContaining("Unexpected response from Beacon Node API");
}
Aggregations