Skip to content

Commit d4e0682

Browse files
committed
Check request
1 parent c6a80e1 commit d4e0682

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

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

+19-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,11 +26,13 @@
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.infrastructure.unsigned.UInt64.ONE;
2931
import static tech.pegasys.teku.spec.config.SpecConfig.FAR_FUTURE_EPOCH;
3032

3133
import com.fasterxml.jackson.core.JsonProcessingException;
3234
import com.fasterxml.jackson.databind.ObjectMapper;
35+
import it.unimi.dsi.fastutil.ints.IntList;
3336
import it.unimi.dsi.fastutil.ints.IntSet;
3437
import java.util.List;
3538
import java.util.Optional;
@@ -44,6 +47,7 @@
4447
import tech.pegasys.teku.ethereum.json.types.beacon.StateValidatorData;
4548
import tech.pegasys.teku.ethereum.json.types.validator.SyncCommitteeDuties;
4649
import tech.pegasys.teku.ethereum.json.types.validator.SyncCommitteeDuty;
50+
import tech.pegasys.teku.infrastructure.json.types.DeserializableTypeDefinition;
4751
import tech.pegasys.teku.infrastructure.ssz.SszDataAssert;
4852
import tech.pegasys.teku.infrastructure.ssz.SszList;
4953
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
@@ -416,7 +420,8 @@ private StateValidatorData generateStateValidatorData() {
416420
}
417421

418422
@TestTemplate
419-
public void postSyncDuties_WhenSuccess_ReturnsResponse() throws JsonProcessingException {
423+
public void postSyncDuties_WhenSuccess_ReturnsResponse()
424+
throws JsonProcessingException, InterruptedException {
420425
final List<SyncCommitteeDuty> duties =
421426
List.of(
422427
new SyncCommitteeDuty(
@@ -428,8 +433,20 @@ public void postSyncDuties_WhenSuccess_ReturnsResponse() throws JsonProcessingEx
428433
final String body = serialize(response, SYNC_COMMITTEE_DUTIES_TYPE);
429434
mockWebServer.enqueue(new MockResponse().setResponseCode(SC_OK).setBody(body));
430435

436+
final UInt64 epoch = ONE;
437+
final IntList validatorIndices = IntList.of(1, 2);
431438
Optional<SyncCommitteeDuties> result =
432-
okHttpValidatorTypeDefClient.postSyncDuties(ONE, IntSet.of(1, 2));
439+
okHttpValidatorTypeDefClient.postSyncDuties(epoch, validatorIndices);
440+
441+
final RecordedRequest recordedRequest = mockWebServer.takeRequest();
442+
assertThat(recordedRequest.getPath()).isEqualTo("/eth/v1/validator/duties/sync/" + epoch);
443+
assertThat(recordedRequest.getMethod()).isEqualTo("POST");
444+
assertThat(recordedRequest.getHeader("Content-Type")).isEqualTo(JSON_CONTENT_TYPE);
445+
assertThat(recordedRequest.getBody().readByteArray())
446+
.isEqualTo(
447+
serialize(validatorIndices, DeserializableTypeDefinition.listOf(INTEGER_TYPE, 1))
448+
.getBytes(UTF_8));
449+
433450
assertThat(result).isPresent();
434451
assertThat(result.get()).isEqualTo(response);
435452
}

0 commit comments

Comments
 (0)