Skip to content

Commit ab450fc

Browse files
committed
Check request
1 parent 86c6505 commit ab450fc

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

Diff for: validator/remote/src/integration-test/java/tech/pegasys/teku/validator/remote/typedef/OkHttpValidatorTypeDefClientTest.java

+18-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
package tech.pegasys.teku.validator.remote.typedef;
1515

16+
import static java.nio.charset.StandardCharsets.UTF_8;
1617
import static java.util.Collections.emptyMap;
1718
import static org.assertj.core.api.Assertions.assertThat;
1819
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -25,6 +26,7 @@
2526
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_NO_CONTENT;
2627
import static tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_OK;
2728
import static tech.pegasys.teku.infrastructure.json.JsonUtil.serialize;
29+
import static tech.pegasys.teku.infrastructure.json.types.CoreTypes.INTEGER_TYPE;
2830
import static tech.pegasys.teku.spec.config.SpecConfig.FAR_FUTURE_EPOCH;
2931

3032
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -43,6 +45,7 @@
4345
import tech.pegasys.teku.ethereum.json.types.beacon.StateValidatorData;
4446
import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuties;
4547
import tech.pegasys.teku.ethereum.json.types.validator.AttesterDuty;
48+
import tech.pegasys.teku.infrastructure.json.types.DeserializableTypeDefinition;
4649
import tech.pegasys.teku.infrastructure.ssz.SszDataAssert;
4750
import tech.pegasys.teku.infrastructure.ssz.SszList;
4851
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
@@ -415,16 +418,29 @@ private StateValidatorData generateStateValidatorData() {
415418
}
416419

417420
@TestTemplate
418-
public void postAttesterDuties_WhenSuccess_ReturnsResponse() throws JsonProcessingException {
421+
public void postAttesterDuties_WhenSuccess_ReturnsResponse()
422+
throws JsonProcessingException, InterruptedException {
419423
final List<AttesterDuty> duties = List.of(randomAttesterDuty(), randomAttesterDuty());
420424
final AttesterDuties response =
421425
new AttesterDuties(true, dataStructureUtil.randomBytes32(), duties);
422426

423427
final String body = serialize(response, ATTESTER_DUTIES_RESPONSE_TYPE);
424428
mockWebServer.enqueue(new MockResponse().setResponseCode(SC_OK).setBody(body));
425429

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());
426433
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));
428444

429445
assertThat(result).isPresent();
430446
assertThat(result.get()).isEqualTo(response);

0 commit comments

Comments
 (0)