Skip to content

Commit

Permalink
Update spec tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmygchen committed Jan 13, 2025
1 parent 2e11554 commit cd77b2c
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 72 deletions.
8 changes: 4 additions & 4 deletions testing/ef_tests/src/cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,26 @@ pub use transition::TransitionTest;
/// to return `true` for the feature in order for the feature test vector to be tested.
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum FeatureName {
Fulu,
Placeholder,
}

impl FeatureName {
pub fn list_all() -> Vec<FeatureName> {
vec![FeatureName::Fulu]
vec![FeatureName::Placeholder]
}

/// `ForkName` to use when running the feature tests.
pub fn fork_name(&self) -> ForkName {
match self {
FeatureName::Fulu => ForkName::Deneb,
FeatureName::Placeholder => ForkName::Fulu,
}
}
}

impl Display for FeatureName {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
FeatureName::Fulu => f.write_str("fulu"),
FeatureName::Placeholder => f.write_str("placeholder"),
}
}
}
Expand Down
8 changes: 2 additions & 6 deletions testing/ef_tests/src/cases/get_custody_columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ impl<E: EthSpec> LoadCase for GetCustodyColumns<E> {
}

impl<E: EthSpec> Case for GetCustodyColumns<E> {
fn is_enabled_for_fork(_fork_name: ForkName) -> bool {
false
}

fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
fork_name.fulu_enabled()
}

fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@ impl<E: EthSpec> LoadCase for KZGComputeCellsAndKZGProofs<E> {
}

impl<E: EthSpec> Case for KZGComputeCellsAndKZGProofs<E> {
fn is_enabled_for_fork(_fork_name: ForkName) -> bool {
false
}

fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
fork_name.fulu_enabled()
}

fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@ impl<E: EthSpec> LoadCase for KZGRecoverCellsAndKZGProofs<E> {
}

impl<E: EthSpec> Case for KZGRecoverCellsAndKZGProofs<E> {
fn is_enabled_for_fork(_fork_name: ForkName) -> bool {
false
}

fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
fork_name.fulu_enabled()
}

fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
Expand Down
8 changes: 2 additions & 6 deletions testing/ef_tests/src/cases/kzg_verify_cell_kzg_proof_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@ impl<E: EthSpec> LoadCase for KZGVerifyCellKZGProofBatch<E> {
}

impl<E: EthSpec> Case for KZGVerifyCellKZGProofBatch<E> {
fn is_enabled_for_fork(_fork_name: ForkName) -> bool {
false
}

fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
fork_name.fulu_enabled()
}

fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
Expand Down
28 changes: 0 additions & 28 deletions testing/ef_tests/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,22 +349,6 @@ where
fn is_enabled_for_fork(&self, fork_name: ForkName) -> bool {
self.supported_forks.contains(&fork_name)
}

fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
// This ensures we only run the tests **once** for `Eip7594`, using the types matching the
// correct fork, e.g. `Eip7594` uses SSZ types from `Deneb` as of spec test version
// `v1.5.0-alpha.8`, therefore the `Eip7594` tests should get included when testing Deneb types.
//
// e.g. Eip7594 test vectors are executed in the first line below, but excluded in the 2nd
// line when testing the type `AttestationElectra`:
//
// ```
// SszStaticHandler::<AttestationBase<MainnetEthSpec>, MainnetEthSpec>::pre_electra().run();
// SszStaticHandler::<AttestationElectra<MainnetEthSpec>, MainnetEthSpec>::electra_only().run();
// ```
feature_name == FeatureName::Fulu
&& self.supported_forks.contains(&feature_name.fork_name())
}
}

impl<E> Handler for SszStaticTHCHandler<BeaconState<E>, E>
Expand All @@ -384,10 +368,6 @@ where
fn handler_name(&self) -> String {
BeaconState::<E>::name().into()
}

fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
}
}

impl<T, E> Handler for SszStaticWithSpecHandler<T, E>
Expand All @@ -409,10 +389,6 @@ where
fn handler_name(&self) -> String {
T::name().into()
}

fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
}
}

#[derive(Derivative)]
Expand Down Expand Up @@ -994,10 +970,6 @@ impl<E: EthSpec + TypeName> Handler for KzgInclusionMerkleProofValidityHandler<E
fn is_enabled_for_fork(&self, fork_name: ForkName) -> bool {
fork_name.deneb_enabled()
}

fn is_enabled_for_feature(&self, feature_name: FeatureName) -> bool {
feature_name == FeatureName::Fulu
}
}

#[derive(Derivative)]
Expand Down
27 changes: 11 additions & 16 deletions testing/ef_tests/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,18 +626,16 @@ mod ssz_static {

#[test]
fn data_column_sidecar() {
SszStaticHandler::<DataColumnSidecar<MinimalEthSpec>, MinimalEthSpec>::deneb_only()
.run_for_feature(FeatureName::Fulu);
SszStaticHandler::<DataColumnSidecar<MainnetEthSpec>, MainnetEthSpec>::deneb_only()
.run_for_feature(FeatureName::Fulu);
SszStaticHandler::<DataColumnSidecar<MinimalEthSpec>, MinimalEthSpec>::fulu_and_later()
.run();
SszStaticHandler::<DataColumnSidecar<MainnetEthSpec>, MainnetEthSpec>::fulu_and_later()
.run();
}

#[test]
fn data_column_identifier() {
SszStaticHandler::<DataColumnIdentifier, MinimalEthSpec>::deneb_only()
.run_for_feature(FeatureName::Fulu);
SszStaticHandler::<DataColumnIdentifier, MainnetEthSpec>::deneb_only()
.run_for_feature(FeatureName::Fulu);
SszStaticHandler::<DataColumnIdentifier, MinimalEthSpec>::fulu_and_later().run();
SszStaticHandler::<DataColumnIdentifier, MainnetEthSpec>::fulu_and_later().run();
}

#[test]
Expand Down Expand Up @@ -901,20 +899,17 @@ fn kzg_verify_kzg_proof() {

#[test]
fn kzg_compute_cells_and_proofs() {
KZGComputeCellsAndKZGProofHandler::<MainnetEthSpec>::default()
.run_for_feature(FeatureName::Fulu);
KZGComputeCellsAndKZGProofHandler::<MainnetEthSpec>::default().run();
}

#[test]
fn kzg_verify_cell_proof_batch() {
KZGVerifyCellKZGProofBatchHandler::<MainnetEthSpec>::default()
.run_for_feature(FeatureName::Fulu);
KZGVerifyCellKZGProofBatchHandler::<MainnetEthSpec>::default().run();
}

#[test]
fn kzg_recover_cells_and_proofs() {
KZGRecoverCellsAndKZGProofHandler::<MainnetEthSpec>::default()
.run_for_feature(FeatureName::Fulu);
KZGRecoverCellsAndKZGProofHandler::<MainnetEthSpec>::default().run();
}

#[test]
Expand Down Expand Up @@ -949,6 +944,6 @@ fn rewards() {

#[test]
fn get_custody_columns() {
GetCustodyColumnsHandler::<MainnetEthSpec>::default().run_for_feature(FeatureName::Fulu);
GetCustodyColumnsHandler::<MinimalEthSpec>::default().run_for_feature(FeatureName::Fulu);
GetCustodyColumnsHandler::<MainnetEthSpec>::default().run();
GetCustodyColumnsHandler::<MinimalEthSpec>::default().run()
}

0 comments on commit cd77b2c

Please sign in to comment.