Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.verifyMetadataErrorResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.io.Resources;
import java.io.IOException;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.api.migrated.AllBlocksAtSlotData;
import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerTest;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.json.JsonTestUtil;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
Expand Down Expand Up @@ -88,12 +89,14 @@ void metadata_shouldHandle503() throws JsonProcessingException {
}

@Test
void metadata_shouldHandle200() throws IOException {
void metadata_shouldHandle200() throws Exception {
final String data = getResponseStringFromMetadata(handler, SC_OK, responseData);
final JsonNode responseDataAsJsonNode = JsonTestUtil.parseAsJsonNode(data);
final String expected =
Resources.toString(
Resources.getResource(GetAllBlocksAtSlotTest.class, "getAllBlocksAtSlot.json"), UTF_8);
assertThat(data).isEqualTo(expected);
final JsonNode expectedAsJsonNode = JsonTestUtil.parseAsJsonNode(expected);
assertThat(responseDataAsJsonNode).isEqualTo(expectedAsJsonNode);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.verifyMetadataErrorResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.io.Resources;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerTest;
import tech.pegasys.teku.infrastructure.json.JsonTestUtil;
import tech.pegasys.teku.spec.datastructures.operations.Attestation;

class GetAttestationsTest extends AbstractMigratedBeaconHandlerTest {
Expand Down Expand Up @@ -74,14 +75,16 @@ void metadata_shouldHandle500() throws JsonProcessingException {
}

@Test
void metadata_shouldHandle200() throws IOException {
void metadata_shouldHandle200() throws Exception {
List<Attestation> responseData =
List.of(dataStructureUtil.randomAttestation(), dataStructureUtil.randomAttestation());

final String data = getResponseStringFromMetadata(handler, SC_OK, responseData);
final JsonNode responseDataAsJsonNode = JsonTestUtil.parseAsJsonNode(data);
final String expected =
Resources.toString(
Resources.getResource(GetAttestationsTest.class, "getAttestations.json"), UTF_8);
assertThat(data).isEqualTo(expected);
final JsonNode expectedAsJsonNode = JsonTestUtil.parseAsJsonNode(expected);
assertThat(responseDataAsJsonNode).isEqualTo(expectedAsJsonNode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.verifyMetadataErrorResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.io.Resources;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerWithChainDataProviderTest;
import tech.pegasys.teku.infrastructure.json.JsonTestUtil;
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.datastructures.metadata.ObjectAndMetaData;
Expand Down Expand Up @@ -75,15 +76,17 @@ void metadata_shouldHandle500() throws JsonProcessingException {
}

@Test
void metadata_shouldHandle200() throws IOException {
void metadata_shouldHandle200() throws Exception {
final SignedBeaconBlock beaconBlock = dataStructureUtil.randomSignedBlindedBeaconBlock(1);
final ObjectAndMetaData<SignedBeaconBlock> responseData = withMetaData(beaconBlock);

final String data = getResponseStringFromMetadata(handler, SC_OK, responseData);
final JsonNode responseDataAsJsonNode = JsonTestUtil.parseAsJsonNode(data);
final String expected =
Resources.toString(
Resources.getResource(GetBlindedBlockTest.class, "getBlindedBlock.json"), UTF_8);
assertThat(data).isEqualTo(expected);
final JsonNode expectedAsJsonNode = JsonTestUtil.parseAsJsonNode(expected);
assertThat(responseDataAsJsonNode).isEqualTo(expectedAsJsonNode);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.verifyMetadataErrorResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.io.Resources;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerTest;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.json.JsonTestUtil;
import tech.pegasys.teku.spec.datastructures.metadata.ObjectAndMetaData;
import tech.pegasys.teku.spec.datastructures.operations.Attestation;

Expand Down Expand Up @@ -74,13 +75,15 @@ void metadata_shouldHandle500() throws JsonProcessingException {
}

@Test
void metadata_shouldHandle200() throws IOException {
void metadata_shouldHandle200() throws Exception {
final String data = getResponseStringFromMetadata(handler, SC_OK, responseData);
final JsonNode responseDataAsJsonNode = JsonTestUtil.parseAsJsonNode(data);
final String expected =
Resources.toString(
Resources.getResource(GetBlockAttestationsTest.class, "getBlockAttestations.json"),
UTF_8);
assertThat(data).isEqualTo(expected);
final JsonNode expectedAsJsonNode = JsonTestUtil.parseAsJsonNode(expected);
assertThat(responseDataAsJsonNode).isEqualTo(expectedAsJsonNode);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.verifyMetadataErrorResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.io.Resources;
import java.io.IOException;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerWithChainDataProviderTest;
import tech.pegasys.teku.bls.BLSSignature;
import tech.pegasys.teku.infrastructure.json.JsonTestUtil;
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
Expand Down Expand Up @@ -79,12 +80,14 @@ void metadata_shouldHandle500() throws JsonProcessingException {
}

@Test
void metadata_shouldHandle200() throws IOException {
void metadata_shouldHandle200() throws Exception {
final String data = getResponseStringFromMetadata(handler, SC_OK, responseData);
final JsonNode responseDataAsJsonNode = JsonTestUtil.parseAsJsonNode(data);
final String expected =
Resources.toString(
Resources.getResource(GetBlockHeaderTest.class, "getBlockHeader.json"), UTF_8);
assertThat(data).isEqualTo(expected);
final JsonNode expectedAsJsonNode = JsonTestUtil.parseAsJsonNode(expected);
assertThat(responseDataAsJsonNode).isEqualTo(expectedAsJsonNode);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.verifyMetadataErrorResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.io.Resources;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.api.migrated.BlockHeadersResponse;
import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerWithChainDataProviderTest;
import tech.pegasys.teku.infrastructure.json.JsonTestUtil;
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.datastructures.metadata.BlockAndMetaData;

Expand Down Expand Up @@ -69,16 +70,18 @@ void metadata_shouldHandle500() throws JsonProcessingException {
}

@Test
void metadata_shouldHandle200() throws IOException {
void metadata_shouldHandle200() throws Exception {
final List<BlockAndMetaData> headers =
List.of(generateBlockHeaderData(), generateBlockHeaderData());
final BlockHeadersResponse responseData = new BlockHeadersResponse(true, false, headers);

final String data = getResponseStringFromMetadata(handler, SC_OK, responseData);
final JsonNode responseDataAsJsonNode = JsonTestUtil.parseAsJsonNode(data);
final String expected =
Resources.toString(
Resources.getResource(GetBlockHeadersTest.class, "getBlockHeaders.json"), UTF_8);
assertThat(data).isEqualTo(expected);
final JsonNode expectedAsJsonNode = JsonTestUtil.parseAsJsonNode(expected);
assertThat(responseDataAsJsonNode).isEqualTo(expectedAsJsonNode);
}

private BlockAndMetaData generateBlockHeaderData() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.verifyMetadataErrorResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.io.Resources;
import java.io.IOException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerWithChainDataProviderTest;
import tech.pegasys.teku.infrastructure.json.JsonTestUtil;
import tech.pegasys.teku.infrastructure.ssz.SszList;
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.capella.BeaconBlockBodyCapella;
Expand Down Expand Up @@ -70,18 +71,19 @@ void metadata_shouldHandle501() throws JsonProcessingException {
}

@Test
void metadata_shouldHandle200() throws IOException {
void metadata_shouldHandle200() throws Exception {
final BeaconBlockBodyCapella beaconBlock =
BeaconBlockBodyCapella.required(dataStructureUtil.randomBeaconBlock(1).getBody());
final ObjectAndMetaData<SszList<Withdrawal>> responseData =
withMetaData(beaconBlock.getExecutionPayload().getWithdrawals());

final String data = getResponseStringFromMetadata(handler, SC_OK, responseData);
final JsonNode responseDataAsJsonNode = JsonTestUtil.parseAsJsonNode(data);
final String expected =
Resources.toString(
Resources.getResource(GetExpectedWithdrawalsTest.class, "getExpectedWithdrawals.json"),
UTF_8);
assertThat(data).isEqualTo(expected);
final JsonNode expectedAsJsonNode = JsonTestUtil.parseAsJsonNode(expected);
assertThat(responseDataAsJsonNode).isEqualTo(expectedAsJsonNode);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.verifyMetadataErrorResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.io.Resources;
import java.io.IOException;
import java.util.Optional;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerTest;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.json.JsonTestUtil;
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.datastructures.metadata.StateAndMetaData;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
Expand Down Expand Up @@ -78,13 +79,14 @@ void metadata_shouldHandle500() throws JsonProcessingException {
}

@Test
void metadata_shouldHandle200() throws IOException {
BeaconState responseData = dataStructureUtil.randomBeaconState();

void metadata_shouldHandle200() throws Exception {
final BeaconState responseData = dataStructureUtil.randomBeaconState();
final String data = getResponseStringFromMetadata(handler, SC_OK, responseData);
final JsonNode responseDataAsJsonNode = JsonTestUtil.parseAsJsonNode(data);
final String expected =
Resources.toString(Resources.getResource(GetStateTest.class, "getState.json"), UTF_8);
assertThat(data).isEqualTo(String.format(expected, responseData.getGenesisTime()));
final JsonNode expectedAsJsonNode = JsonTestUtil.parseAsJsonNode(expected);
assertThat(responseDataAsJsonNode).isEqualTo(expectedAsJsonNode);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.verifyMetadataErrorResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.io.Resources;
import java.io.IOException;
import java.util.Optional;
import org.apache.tuweni.bytes.Bytes32;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerTest;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.json.JsonTestUtil;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.datastructures.operations.Attestation;

Expand Down Expand Up @@ -76,15 +77,16 @@ void metadata_shouldHandle500() throws JsonProcessingException {
}

@Test
void metadata_shouldHandle200() throws IOException {
Attestation responseData = dataStructureUtil.randomAttestation();

void metadata_shouldHandle200() throws Exception {
final Attestation responseData = dataStructureUtil.randomAttestation();
final String data = getResponseStringFromMetadata(handler, SC_OK, responseData);
final JsonNode responseDataAsJsonNode = JsonTestUtil.parseAsJsonNode(data);
final String expected =
Resources.toString(
Resources.getResource(
GetAggregateAttestationTest.class, "getAggregateAttestation.json"),
UTF_8);
assertThat(data).isEqualTo(expected);
final JsonNode expectedAsJsonNode = JsonTestUtil.parseAsJsonNode(expected);
assertThat(responseDataAsJsonNode).isEqualTo(expectedAsJsonNode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.verifyMetadataErrorResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.io.Resources;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerWithChainDataProviderTest;
import tech.pegasys.teku.infrastructure.json.JsonTestUtil;
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.datastructures.metadata.ObjectAndMetaData;
Expand Down Expand Up @@ -75,14 +76,15 @@ void metadata_shouldHandle500() throws JsonProcessingException {
}

@Test
void metadata_shouldHandle200() throws IOException {
void metadata_shouldHandle200() throws Exception {
final SignedBeaconBlock beaconBlock = dataStructureUtil.randomSignedBeaconBlock(1);
final ObjectAndMetaData<SignedBeaconBlock> responseData = withMetaData(beaconBlock);

final String data = getResponseStringFromMetadata(handler, SC_OK, responseData);
final JsonNode responseDataAsJsonNode = JsonTestUtil.parseAsJsonNode(data);
final String expected =
Resources.toString(Resources.getResource(GetBlockTest.class, "getBlock.json"), UTF_8);
assertThat(data).isEqualTo(expected);
final JsonNode expectedAsJsonNode = JsonTestUtil.parseAsJsonNode(expected);
assertThat(responseDataAsJsonNode).isEqualTo(expectedAsJsonNode);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@
import static tech.pegasys.teku.spec.SpecMilestone.PHASE0;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.io.Resources;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerWithChainDataProviderTest;
import tech.pegasys.teku.infrastructure.json.JsonTestUtil;
import tech.pegasys.teku.spec.datastructures.metadata.StateAndMetaData;

class GetStateTest extends AbstractMigratedBeaconHandlerWithChainDataProviderTest {
Expand Down Expand Up @@ -74,7 +75,7 @@ void metadata_shouldHandle500() throws JsonProcessingException {
}

@Test
void metadata_shouldHandle200() throws IOException {
void metadata_shouldHandle200() throws Exception {
final StateAndMetaData responseData =
new StateAndMetaData(
dataStructureUtil.randomBeaconState(),
Expand All @@ -84,9 +85,11 @@ void metadata_shouldHandle200() throws IOException {
false);

final String data = getResponseStringFromMetadata(handler, SC_OK, responseData);
final JsonNode responseDataAsJsonNode = JsonTestUtil.parseAsJsonNode(data);
final String expected =
Resources.toString(Resources.getResource(GetStateTest.class, "getState.json"), UTF_8);
assertThat(data).isEqualTo(String.format(expected, responseData.getData().getGenesisTime()));
final JsonNode expectedAsJsonNode = JsonTestUtil.parseAsJsonNode(expected);
assertThat(responseDataAsJsonNode).isEqualTo(expectedAsJsonNode);
}

@Test
Expand Down
Loading