Skip to content

Commit

Permalink
fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdi-aouadi committed Jul 19, 2024
1 parent 683d425 commit fc13e5f
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package tech.pegasys.teku.beaconrestapi.v2.beacon;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.Mockito.when;
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_BAD_REQUEST;
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_OK;
Expand Down Expand Up @@ -57,12 +56,12 @@ void setup(final TestSpecInvocationContextProvider.SpecContext specContext) {

@TestTemplate
void shouldPostAttestations_NoErrors() throws Exception {
when(validatorApiChannel.sendSignedAttestations(anyList()))
.thenReturn(SafeFuture.completedFuture(Collections.emptyList()));

final List<Attestation> attestations =
List.of(dataStructureUtil.randomAttestation(), dataStructureUtil.randomAttestation());

when(validatorApiChannel.sendSignedAttestationsV2(specMilestone, attestations))
.thenReturn(SafeFuture.completedFuture(Collections.emptyList()));

final Response response =
post(
PostAttestationsV2.ROUTE,
Expand All @@ -87,16 +86,17 @@ void shouldPartiallyPostAttestations_ReturnsErrors() throws Exception {
new SubmitDataError(UInt64.ZERO, "Bad attestation");
final SubmitDataError secondSubmitDataError =
new SubmitDataError(UInt64.ONE, "Very bad attestation");
when(validatorApiChannel.sendSignedAttestations(anyList()))
.thenReturn(
SafeFuture.completedFuture(List.of(firstSubmitDataError, secondSubmitDataError)));

final List<Attestation> attestations =
List.of(
dataStructureUtil.randomAttestation(),
dataStructureUtil.randomAttestation(),
dataStructureUtil.randomAttestation());

when(validatorApiChannel.sendSignedAttestationsV2(specMilestone, attestations))
.thenReturn(
SafeFuture.completedFuture(List.of(firstSubmitDataError, secondSubmitDataError)));

final Response response =
post(
PostAttestationsV2.ROUTE,
Expand Down Expand Up @@ -129,12 +129,12 @@ void shouldPartiallyPostAttestations_ReturnsErrors() throws Exception {

@TestTemplate
void shouldFailWhenMissingConsensusHeader() throws Exception {
when(validatorApiChannel.sendSignedAttestations(anyList()))
.thenReturn(SafeFuture.completedFuture(Collections.emptyList()));

final List<Attestation> attestations =
List.of(dataStructureUtil.randomAttestation(), dataStructureUtil.randomAttestation());

when(validatorApiChannel.sendSignedAttestationsV2(specMilestone, attestations))
.thenReturn(SafeFuture.completedFuture(Collections.emptyList()));

final Response response =
post(
PostAttestationsV2.ROUTE,
Expand All @@ -156,12 +156,12 @@ void shouldFailWhenMissingConsensusHeader() throws Exception {

@TestTemplate
void shouldFailWhenBadConsensusHeaderValue() throws Exception {
when(validatorApiChannel.sendSignedAttestations(anyList()))
.thenReturn(SafeFuture.completedFuture(Collections.emptyList()));

final List<Attestation> attestations =
List.of(dataStructureUtil.randomAttestation(), dataStructureUtil.randomAttestation());

when(validatorApiChannel.sendSignedAttestationsV2(specMilestone, attestations))
.thenReturn(SafeFuture.completedFuture(Collections.emptyList()));

final Response response =
post(
PostAttestationsV2.ROUTE,
Expand Down

0 comments on commit fc13e5f

Please sign in to comment.