Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added test case for comparing mainnet config output #8917

Merged
merged 7 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,20 @@
import static tech.pegasys.teku.infrastructure.restapi.MetadataTestUtil.verifyMetadataErrorResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.io.Resources;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.api.ConfigProvider;
import tech.pegasys.teku.api.SpecConfigData;
import tech.pegasys.teku.beaconrestapi.AbstractMigratedBeaconHandlerTest;
import tech.pegasys.teku.spec.SpecFactory;

class GetSpecTest extends AbstractMigratedBeaconHandlerTest {
private final ConfigProvider configProvider = new ConfigProvider(spec);
private final SpecConfigData response = new SpecConfigData(configProvider.getSpecConfig());
private final ObjectMapper mapper = new ObjectMapper();

@BeforeEach
void setUp() {
Expand All @@ -51,4 +56,17 @@ void metadata_shouldHandle400() throws JsonProcessingException {
void metadata_shouldHandle500() throws JsonProcessingException {
verifyMetadataErrorResponse(handler, SC_INTERNAL_SERVER_ERROR);
}

@Test
@SuppressWarnings("unchecked")
void shouldGetCorrectMainnetConfig() throws Exception {
final ConfigProvider configProvider = new ConfigProvider(SpecFactory.create("mainnet"));
setHandler(new GetSpec(configProvider));
handler.handleRequest(request);
final JsonNode data = mapper.valueToTree(request.getResponseBody());
// re-parsing so that the output is consistent, then we can use the same prettyPrint
final JsonNode expected =
mapper.readTree(Resources.getResource(GetSpecTest.class, "mainnetConfig.json"));
assertThat(data.toPrettyString()).isEqualTo(expected.toPrettyString());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
"SLOTS_PER_EPOCH" : "32",
"PRESET_BASE" : "mainnet",
"TERMINAL_TOTAL_DIFFICULTY" : "58750000000000000000000",
"INACTIVITY_SCORE_BIAS" : "4",
"MAX_ATTESTER_SLASHINGS" : "2",
"MAX_WITHDRAWALS_PER_PAYLOAD" : "16",
"INACTIVITY_PENALTY_QUOTIENT_BELLATRIX" : "16777216",
"PENDING_PARTIAL_WITHDRAWALS_LIMIT" : "134217728",
"INACTIVITY_PENALTY_QUOTIENT" : "67108864",
"SAFE_SLOTS_TO_UPDATE_JUSTIFIED" : "8",
"SECONDS_PER_ETH1_BLOCK" : "14",
"MIN_SEED_LOOKAHEAD" : "1",
"VALIDATOR_REGISTRY_LIMIT" : "1099511627776",
"REORG_MAX_EPOCHS_SINCE_FINALIZATION" : "2",
"SLOTS_PER_HISTORICAL_ROOT" : "8192",
"RESP_TIMEOUT" : "10",
"DOMAIN_VOLUNTARY_EXIT" : "0x04000000",
"MAX_VALIDATORS_PER_COMMITTEE" : "2048",
"MIN_GENESIS_TIME" : "1606824000",
"ALTAIR_FORK_EPOCH" : "74240",
"MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT" : "256000000000",
"HYSTERESIS_QUOTIENT" : "4",
"ALTAIR_FORK_VERSION" : "0x01000000",
"MAX_BYTES_PER_TRANSACTION" : "1073741824",
"MAX_CHUNK_SIZE" : "10485760",
"TTFB_TIMEOUT" : "5",
"WHISTLEBLOWER_REWARD_QUOTIENT" : "512",
"PROPOSER_REWARD_QUOTIENT" : "8",
"MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP" : "16384",
"EPOCHS_PER_HISTORICAL_VECTOR" : "65536",
"MIN_PER_EPOCH_CHURN_LIMIT" : "4",
"MAX_ATTESTER_SLASHINGS_ELECTRA" : "1",
"TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE" : "16",
"MAX_DEPOSITS" : "16",
"BELLATRIX_FORK_EPOCH" : "144896",
"MAX_REQUEST_BLOB_SIDECARS" : "768",
"REORG_HEAD_WEIGHT_THRESHOLD" : "20",
"TARGET_AGGREGATORS_PER_COMMITTEE" : "16",
"DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF" : "0x08000000",
"MESSAGE_DOMAIN_INVALID_SNAPPY" : "0x00000000",
"EPOCHS_PER_SLASHINGS_VECTOR" : "8192",
"MIN_SLASHING_PENALTY_QUOTIENT" : "128",
"MAX_BLS_TO_EXECUTION_CHANGES" : "16",
"GOSSIP_MAX_SIZE" : "10485760",
"TARGET_BLOBS_PER_BLOCK_ELECTRA" : "3",
"DOMAIN_BEACON_ATTESTER" : "0x01000000",
"EPOCHS_PER_SUBNET_SUBSCRIPTION" : "256",
"PENDING_DEPOSITS_LIMIT" : "134217728",
"MAX_ATTESTATIONS_ELECTRA" : "8",
"ATTESTATION_SUBNET_COUNT" : "64",
"GENESIS_DELAY" : "604800",
"MAX_SEED_LOOKAHEAD" : "4",
"ETH1_FOLLOW_DISTANCE" : "2048",
"SECONDS_PER_SLOT" : "12",
"REORG_PARENT_WEIGHT_THRESHOLD" : "160",
"MIN_SYNC_COMMITTEE_PARTICIPANTS" : "1",
"MAX_PENDING_DEPOSITS_PER_EPOCH" : "16",
"BELLATRIX_FORK_VERSION" : "0x02000000",
"PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX" : "3",
"EFFECTIVE_BALANCE_INCREMENT" : "1000000000",
"MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA" : "128000000000",
"FIELD_ELEMENTS_PER_BLOB" : "4096",
"MIN_EPOCHS_TO_INACTIVITY_PENALTY" : "4",
"BASE_REWARD_FACTOR" : "64",
"MAX_EXTRA_DATA_BYTES" : "32",
"CONFIG_NAME" : "mainnet",
"MAX_PROPOSER_SLASHINGS" : "16",
"INACTIVITY_SCORE_RECOVERY_RATE" : "16",
"MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS" : "4096",
"MAX_TRANSACTIONS_PER_PAYLOAD" : "1048576",
"DEPOSIT_CONTRACT_ADDRESS" : "0x00000000219ab540356cBB839Cbe05303d7705Fa",
"MIN_ATTESTATION_INCLUSION_DELAY" : "1",
"SHUFFLE_ROUND_COUNT" : "90",
"TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH" : "18446744073709551615",
"MAX_EFFECTIVE_BALANCE" : "32000000000",
"DOMAIN_BEACON_PROPOSER" : "0x00000000",
"DENEB_FORK_EPOCH" : "269568",
"DOMAIN_SYNC_COMMITTEE" : "0x07000000",
"PROPOSER_SCORE_BOOST" : "40",
"DOMAIN_SELECTION_PROOF" : "0x05000000",
"MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX" : "32",
"MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT" : "8",
"HYSTERESIS_UPWARD_MULTIPLIER" : "5",
"SUBNETS_PER_NODE" : "2",
"MIN_DEPOSIT_AMOUNT" : "1000000000",
"MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA" : "4096",
"PROPORTIONAL_SLASHING_MULTIPLIER_ALTAIR" : "2",
"MAX_BLOBS_PER_BLOCK" : "6",
"MIN_VALIDATOR_WITHDRAWABILITY_DELAY" : "256",
"MAXIMUM_GOSSIP_CLOCK_DISPARITY" : "500",
"TARGET_COMMITTEE_SIZE" : "128",
"TERMINAL_BLOCK_HASH" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"DOMAIN_DEPOSIT" : "0x03000000",
"DOMAIN_CONTRIBUTION_AND_PROOF" : "0x09000000",
"UPDATE_TIMEOUT" : "8192",
"ELECTRA_FORK_EPOCH" : "18446744073709551615",
"SYNC_COMMITTEE_BRANCH_LENGTH" : "5",
"DEPOSIT_CHAIN_ID" : "1",
"MAX_BLOB_COMMITMENTS_PER_BLOCK" : "4096",
"DOMAIN_RANDAO" : "0x02000000",
"CAPELLA_FORK_VERSION" : "0x03000000",
"MAX_EFFECTIVE_BALANCE_ELECTRA" : "2048000000000",
"MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR" : "64",
"EPOCHS_PER_ETH1_VOTING_PERIOD" : "64",
"WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA" : "4096",
"HISTORICAL_ROOTS_LIMIT" : "16777216",
"ATTESTATION_PROPAGATION_SLOT_RANGE" : "32",
"MAX_BLOBS_PER_BLOCK_ELECTRA" : "6",
"SYNC_COMMITTEE_SIZE" : "512",
"ATTESTATION_SUBNET_PREFIX_BITS" : "6",
"PROPORTIONAL_SLASHING_MULTIPLIER" : "1",
"MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD" : "16",
"MESSAGE_DOMAIN_VALID_SNAPPY" : "0x01000000",
"MAX_VOLUNTARY_EXITS" : "16",
"PENDING_CONSOLIDATIONS_LIMIT" : "262144",
"HYSTERESIS_DOWNWARD_MULTIPLIER" : "1",
"DOMAIN_APPLICATION_BUILDER" : "0x00000001",
"MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP" : "8",
"EPOCHS_PER_SYNC_COMMITTEE_PERIOD" : "256",
"BYTES_PER_LOGS_BLOOM" : "256",
"MAX_DEPOSIT_REQUESTS_PER_PAYLOAD" : "8192",
"MIN_GENESIS_ACTIVE_VALIDATOR_COUNT" : "16384",
"MAX_REQUEST_BLOB_SIDECARS_ELECTRA" : "768",
"BLOB_SIDECAR_SUBNET_COUNT_ELECTRA" : "6",
"MAX_ATTESTATIONS" : "128",
"MIN_EPOCHS_FOR_BLOCK_REQUESTS" : "33024",
"DENEB_FORK_VERSION" : "0x04000000",
"ELECTRA_FORK_VERSION" : "0x05000000",
"MAX_REQUEST_BLOCKS" : "1024",
"GENESIS_FORK_VERSION" : "0x00000000",
"KZG_COMMITMENT_INCLUSION_PROOF_DEPTH" : "17",
"DEPOSIT_NETWORK_ID" : "1",
"MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD" : "1",
"MAX_REQUEST_BLOCKS_DENEB" : "128",
"BLOB_SIDECAR_SUBNET_COUNT" : "6",
"SYNC_COMMITTEE_SUBNET_COUNT" : "4",
"CAPELLA_FORK_EPOCH" : "194048",
"EJECTION_BALANCE" : "16000000000",
"ATTESTATION_SUBNET_EXTRA_BITS" : "0",
"MAX_COMMITTEES_PER_SLOT" : "64",
"SHARD_COMMITTEE_PERIOD" : "256",
"INACTIVITY_PENALTY_QUOTIENT_ALTAIR" : "50331648",
"DOMAIN_AGGREGATE_AND_PROOF" : "0x06000000",
"CHURN_LIMIT_QUOTIENT" : "65536",
"BLS_WITHDRAWAL_PREFIX" : "0x00",
"MIN_ACTIVATION_BALANCE" : "32000000000"
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public static Map<String, Object> parse(final String json) throws Exception {
.readValue(json);
}

public static Map<String, String> parseStringMap(final String json) throws Exception {
tbenr marked this conversation as resolved.
Show resolved Hide resolved
return new ObjectMapper()
.readerFor(
TypeFactory.defaultInstance()
.constructMapType(LinkedHashMap.class, String.class, String.class))
.readValue(json);
}

public static String parseString(final String json) throws Exception {
return new ObjectMapper().readerFor(String.class).readValue(json);
}
Expand Down
Loading