Skip to content

Commit

Permalink
fixing unit tests (Consensys#4346)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbenr committed Sep 16, 2021
1 parent 6d50c6c commit 47b5a9d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static tech.pegasys.teku.beaconrestapi.RestApiConstants.EXECUTION_PAYLOAD_ID;
import static tech.pegasys.teku.beaconrestapi.RestApiConstants.RANDAO_REVEAL;
import static tech.pegasys.teku.beaconrestapi.RestApiConstants.SLOT;
import static tech.pegasys.teku.infrastructure.unsigned.UInt64.ONE;
Expand Down Expand Up @@ -77,7 +78,7 @@ void shouldRequireThatRandaoRevealIsSet() throws Exception {
void shouldReturnBlockWithoutGraffiti() throws Exception {
final Map<String, String> pathParams = Map.of(SLOT, "1");
final Map<String, List<String>> queryParams =
Map.of(RANDAO_REVEAL, List.of(signature.toHexString()));
Map.of(RANDAO_REVEAL, List.of(signature.toHexString()), EXECUTION_PAYLOAD_ID, List.of("0"));
Optional<BeaconBlock> optionalBeaconBlock =
Optional.of(
new BeaconBlock(dataStructureUtil.randomBeaconBlock(dataStructureUtil.randomLong())));
Expand All @@ -102,7 +103,9 @@ void shouldReturnBlockWithGraffiti() throws Exception {
RANDAO_REVEAL,
List.of(signature.toHexString()),
RestApiConstants.GRAFFITI,
List.of(graffiti.toHexString()));
List.of(graffiti.toHexString()),
EXECUTION_PAYLOAD_ID,
List.of("0"));
Optional<BeaconBlock> optionalBeaconBlock =
Optional.of(
new BeaconBlock(dataStructureUtil.randomBeaconBlock(dataStructureUtil.randomLong())));
Expand All @@ -124,7 +127,7 @@ void shouldReturnBlockWithGraffiti() throws Exception {
@Test
void shouldReturnServerErrorWhenRuntimeExceptionReceived() throws Exception {
final Map<String, List<String>> params =
Map.of(RANDAO_REVEAL, List.of(signature.toHexString()));
Map.of(RANDAO_REVEAL, List.of(signature.toHexString()), EXECUTION_PAYLOAD_ID, List.of("0"));
when(context.queryParamMap()).thenReturn(params);
when(context.pathParamMap()).thenReturn(Map.of(SLOT, "1"));
when(provider.getMilestoneAtSlot(UInt64.ONE)).thenReturn(SpecMilestone.PHASE0);
Expand All @@ -143,7 +146,7 @@ void shouldReturnServerErrorWhenRuntimeExceptionReceived() throws Exception {
void shouldReturnBadRequestErrorWhenIllegalArgumentExceptionReceived() throws Exception {

final Map<String, List<String>> params =
Map.of(RANDAO_REVEAL, List.of(signature.toHexString()));
Map.of(RANDAO_REVEAL, List.of(signature.toHexString()), EXECUTION_PAYLOAD_ID, List.of("0"));
when(context.pathParamMap()).thenReturn(Map.of(SLOT, "1"));
when(context.queryParamMap()).thenReturn(params);
when(provider.getMilestoneAtSlot(UInt64.ONE)).thenReturn(SpecMilestone.PHASE0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static tech.pegasys.teku.beaconrestapi.RestApiConstants.EXECUTION_PAYLOAD_ID;
import static tech.pegasys.teku.beaconrestapi.RestApiConstants.RANDAO_REVEAL;
import static tech.pegasys.teku.beaconrestapi.RestApiConstants.SLOT;
import static tech.pegasys.teku.infrastructure.unsigned.UInt64.ONE;
Expand Down Expand Up @@ -66,7 +67,7 @@ void shouldReturnBlockWithoutGraffiti() throws Exception {
final Map<String, String> pathParams = Map.of(SLOT, "1");
final SchemaObjectProvider schemaProvider = new SchemaObjectProvider(spec);
final Map<String, List<String>> queryParams =
Map.of(RANDAO_REVEAL, List.of(signature.toHexString()));
Map.of(RANDAO_REVEAL, List.of(signature.toHexString()), EXECUTION_PAYLOAD_ID, List.of("0"));

final tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock randomBeaconBlock =
dataStructureUtil.randomBeaconBlock(ONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ public Optional<BeaconBlock> createUnsignedBlock(
final BLSSignature randaoReveal,
final Optional<Bytes32> graffiti,
final UInt64 executionPayloadId) {
final Map<String, String> pathParams =
Map.of("slot", slot.toString(), "execution_payload_id", executionPayloadId.toString());
final Map<String, String> pathParams = Map.of("slot", slot.toString());
final Map<String, String> queryParams = new HashMap<>();
queryParams.put("randao_reveal", encodeQueryParam(randaoReveal));
graffiti.ifPresent(bytes32 -> queryParams.put("graffiti", encodeQueryParam(bytes32)));
queryParams.put("execution_payload_id", encodeQueryParam(executionPayloadId.toString()));

if (useV2CreateBlock) {
return get(
Expand Down

0 comments on commit 47b5a9d

Please sign in to comment.