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 .infrastructure .unsigned .UInt64 .ONE ;
29
31
import static tech .pegasys .teku .spec .config .SpecConfig .FAR_FUTURE_EPOCH ;
30
32
31
33
import com .fasterxml .jackson .core .JsonProcessingException ;
32
34
import com .fasterxml .jackson .databind .ObjectMapper ;
35
+ import it .unimi .dsi .fastutil .ints .IntList ;
33
36
import it .unimi .dsi .fastutil .ints .IntSet ;
34
37
import java .util .List ;
35
38
import java .util .Optional ;
44
47
import tech .pegasys .teku .ethereum .json .types .beacon .StateValidatorData ;
45
48
import tech .pegasys .teku .ethereum .json .types .validator .SyncCommitteeDuties ;
46
49
import tech .pegasys .teku .ethereum .json .types .validator .SyncCommitteeDuty ;
50
+ import tech .pegasys .teku .infrastructure .json .types .DeserializableTypeDefinition ;
47
51
import tech .pegasys .teku .infrastructure .ssz .SszDataAssert ;
48
52
import tech .pegasys .teku .infrastructure .ssz .SszList ;
49
53
import tech .pegasys .teku .infrastructure .unsigned .UInt64 ;
@@ -416,7 +420,8 @@ private StateValidatorData generateStateValidatorData() {
416
420
}
417
421
418
422
@ TestTemplate
419
- public void postSyncDuties_WhenSuccess_ReturnsResponse () throws JsonProcessingException {
423
+ public void postSyncDuties_WhenSuccess_ReturnsResponse ()
424
+ throws JsonProcessingException , InterruptedException {
420
425
final List <SyncCommitteeDuty > duties =
421
426
List .of (
422
427
new SyncCommitteeDuty (
@@ -428,8 +433,20 @@ public void postSyncDuties_WhenSuccess_ReturnsResponse() throws JsonProcessingEx
428
433
final String body = serialize (response , SYNC_COMMITTEE_DUTIES_TYPE );
429
434
mockWebServer .enqueue (new MockResponse ().setResponseCode (SC_OK ).setBody (body ));
430
435
436
+ final UInt64 epoch = ONE ;
437
+ final IntList validatorIndices = IntList .of (1 , 2 );
431
438
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
+
433
450
assertThat (result ).isPresent ();
434
451
assertThat (result .get ()).isEqualTo (response );
435
452
}
0 commit comments