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

In SpecVersion, make SpecConfig instance consistent with milestone #8830

Merged
merged 6 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
cleanup require methods for SpecConfigAndParent
  • Loading branch information
tbenr committed Nov 14, 2024
commit bde4c15fe97834b47de31b7f1139c057c22f18a6
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

package tech.pegasys.teku.spec.config;

import static com.google.common.base.Preconditions.checkArgument;

import java.util.Optional;
import tech.pegasys.teku.spec.SpecMilestone;

Expand All @@ -40,45 +38,4 @@ public SpecConfig forMilestone(final SpecMilestone milestone) {
}
return parentSpecConfig.get().forMilestone(milestone);
}

@SuppressWarnings("unchecked")
public static SpecConfigAndParent<SpecConfigPhase0> requirePhase0(
final SpecConfigAndParent<? extends SpecConfig> specConfigAndParent) {
return (SpecConfigAndParent<SpecConfigPhase0>) specConfigAndParent;
}

@SuppressWarnings("unchecked")
public static SpecConfigAndParent<SpecConfigAltair> requireAltair(
final SpecConfigAndParent<? extends SpecConfig> specConfigAndParent) {
checkArgument(specConfigAndParent.specConfig.toVersionAltair().isPresent());
return (SpecConfigAndParent<SpecConfigAltair>) specConfigAndParent;
}

@SuppressWarnings("unchecked")
public static SpecConfigAndParent<SpecConfigBellatrix> requireBellatrix(
final SpecConfigAndParent<? extends SpecConfig> specConfigAndParent) {
checkArgument(specConfigAndParent.specConfig.toVersionBellatrix().isPresent());
return (SpecConfigAndParent<SpecConfigBellatrix>) specConfigAndParent;
}

@SuppressWarnings("unchecked")
public static SpecConfigAndParent<SpecConfigCapella> requireCapella(
final SpecConfigAndParent<? extends SpecConfig> specConfigAndParent) {
checkArgument(specConfigAndParent.specConfig.toVersionCapella().isPresent());
return (SpecConfigAndParent<SpecConfigCapella>) specConfigAndParent;
}

@SuppressWarnings("unchecked")
public static SpecConfigAndParent<SpecConfigDeneb> requireDeneb(
final SpecConfigAndParent<? extends SpecConfig> specConfigAndParent) {
checkArgument(specConfigAndParent.specConfig.toVersionDeneb().isPresent());
return (SpecConfigAndParent<SpecConfigDeneb>) specConfigAndParent;
}

@SuppressWarnings("unchecked")
public static SpecConfigAndParent<SpecConfigElectra> requireElectra(
final SpecConfigAndParent<? extends SpecConfig> specConfigAndParent) {
checkArgument(specConfigAndParent.specConfig.toVersionElectra().isPresent());
return (SpecConfigAndParent<SpecConfigElectra>) specConfigAndParent;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.config.SpecConfig;
import tech.pegasys.teku.spec.config.SpecConfigAltair;
import tech.pegasys.teku.spec.config.SpecConfigAndParent;
import tech.pegasys.teku.spec.config.SpecConfigBellatrix;
import tech.pegasys.teku.spec.config.SpecConfigCapella;
import tech.pegasys.teku.spec.config.SpecConfigDeneb;
Expand All @@ -31,25 +30,30 @@

public class SpecMilestoneTest {
private final SpecConfigElectra electraSpecConfig =
SpecConfigAndParent.requireElectra(
SpecConfigLoader.loadConfig(Eth2Network.MINIMAL.configName()))
.specConfig();
SpecConfigLoader.loadConfig(Eth2Network.MINIMAL.configName())
.specConfig()
.toVersionElectra()
.orElseThrow();
private final SpecConfigDeneb denebSpecConfig =
SpecConfigAndParent.requireDeneb(
SpecConfigLoader.loadConfig(Eth2Network.MINIMAL.configName()))
.specConfig();
SpecConfigLoader.loadConfig(Eth2Network.MINIMAL.configName())
.specConfig()
.toVersionDeneb()
.orElseThrow();
private final SpecConfigCapella capellaSpecConfig =
SpecConfigAndParent.requireCapella(
SpecConfigLoader.loadConfig(Eth2Network.MINIMAL.configName()))
.specConfig();
SpecConfigLoader.loadConfig(Eth2Network.MINIMAL.configName())
.specConfig()
.toVersionCapella()
.orElseThrow();
private final SpecConfigBellatrix bellatrixSpecConfig =
SpecConfigAndParent.requireBellatrix(
SpecConfigLoader.loadConfig(Eth2Network.MINIMAL.configName()))
.specConfig();
SpecConfigLoader.loadConfig(Eth2Network.MINIMAL.configName())
.specConfig()
.toVersionBellatrix()
.orElseThrow();
private final SpecConfigAltair altairSpecConfig =
SpecConfigAndParent.requireAltair(
SpecConfigLoader.loadConfig(Eth2Network.MINIMAL.configName()))
.specConfig();
SpecConfigLoader.loadConfig(Eth2Network.MINIMAL.configName())
.specConfig()
.toVersionAltair()
.orElseThrow();
private final SpecConfig phase0SpecConfig =
SpecConfigLoader.loadConfig(Eth2Network.MINIMAL.configName()).specConfig();

Expand Down
Loading