|
13 | 13 |
|
14 | 14 | package tech.pegasys.teku.validator.remote.typedef;
|
15 | 15 |
|
| 16 | +import static java.nio.charset.StandardCharsets.UTF_8; |
16 | 17 | import static java.util.Collections.emptyMap;
|
17 | 18 | import static org.assertj.core.api.Assertions.assertThat;
|
18 | 19 | import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
|
25 | 26 | import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_NO_CONTENT;
|
26 | 27 | import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_OK;
|
27 | 28 | import static tech.pegasys.teku.infrastructure.json.JsonUtil.serialize;
|
| 29 | +import static tech.pegasys.teku.infrastructure.json.types.CoreTypes.INTEGER_TYPE; |
28 | 30 | import static tech.pegasys.teku.spec.config.SpecConfig.FAR_FUTURE_EPOCH;
|
29 | 31 |
|
30 | 32 | import com.fasterxml.jackson.core.JsonProcessingException;
|
|
43 | 45 | import tech.pegasys.teku.ethereum.json.types.beacon.StateValidatorData;
|
44 | 46 | import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuties;
|
45 | 47 | import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuty;
|
| 48 | +import tech.pegasys.teku.infrastructure.json.types.DeserializableTypeDefinition; |
46 | 49 | import tech.pegasys.teku.infrastructure.ssz.SszDataAssert;
|
47 | 50 | import tech.pegasys.teku.infrastructure.ssz.SszList;
|
48 | 51 | import tech.pegasys.teku.infrastructure.unsigned.UInt64;
|
@@ -415,16 +418,29 @@ private StateValidatorData generateStateValidatorData() {
|
415 | 418 | }
|
416 | 419 |
|
417 | 420 | @TestTemplate
|
418 |
| - public void postAttesterDuties_WhenSuccess_ReturnsResponse() throws JsonProcessingException { |
| 421 | + public void postAttesterDuties_WhenSuccess_ReturnsResponse() |
| 422 | + throws JsonProcessingException, InterruptedException { |
419 | 423 | final List<AttesterDuty> duties = List.of(randomAttesterDuty(), randomAttesterDuty());
|
420 | 424 | final AttesterDuties response =
|
421 | 425 | new AttesterDuties(true, dataStructureUtil.randomBytes32(), duties);
|
422 | 426 |
|
423 | 427 | final String body = serialize(response, ATTESTER_DUTIES_RESPONSE_TYPE);
|
424 | 428 | mockWebServer.enqueue(new MockResponse().setResponseCode(SC_OK).setBody(body));
|
425 | 429 |
|
| 430 | + final UInt64 epoch = UInt64.ONE; |
| 431 | + final List<Integer> validatorIndices = List.of(1, 2); |
| 432 | + final IntSet validatorSet = IntSet.of(validatorIndices.stream().mapToInt(i -> i).toArray()); |
426 | 433 | Optional<AttesterDuties> result =
|
427 |
| - okHttpValidatorTypeDefClient.postAttesterDuties(UInt64.ONE, IntSet.of(1, 2)); |
| 434 | + okHttpValidatorTypeDefClient.postAttesterDuties(epoch, validatorSet); |
| 435 | + |
| 436 | + final RecordedRequest recordedRequest = mockWebServer.takeRequest(); |
| 437 | + assertThat(recordedRequest.getPath()).isEqualTo("/eth/v1/validator/duties/attester/" + epoch); |
| 438 | + assertThat(recordedRequest.getMethod()).isEqualTo("POST"); |
| 439 | + assertThat(recordedRequest.getHeader("Content-Type")).isEqualTo(JSON_CONTENT_TYPE); |
| 440 | + assertThat(recordedRequest.getBody().readByteArray()) |
| 441 | + .isEqualTo( |
| 442 | + serialize(validatorIndices, DeserializableTypeDefinition.listOf(INTEGER_TYPE, 1)) |
| 443 | + .getBytes(UTF_8)); |
428 | 444 |
|
429 | 445 | assertThat(result).isPresent();
|
430 | 446 | assertThat(result.get()).isEqualTo(response);
|
|
0 commit comments