Skip to content

Commit f492b92

Browse files
authored
Merge of #6737
2 parents 348fbdb + 898d05e commit f492b92

13 files changed

+103
-56
lines changed

testing/ef_tests/src/cases.rs

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,37 @@ pub use ssz_generic::*;
7474
pub use ssz_static::*;
7575
pub use transition::TransitionTest;
7676

77-
#[derive(Debug, PartialEq)]
77+
/// Used for running feature tests for future forks that have not yet been added to `ForkName`.
78+
/// This runs tests in the directory named by the feature instead of the fork name. This has been
79+
/// the pattern used in the `consensus-spec-tests` repository:
80+
/// `consensus-spec-tests/tests/general/[feature_name]/[runner_name].`
81+
/// e.g. consensus-spec-tests/tests/general/peerdas/ssz_static
82+
///
83+
/// The feature tests can be run with one of the following methods:
84+
/// 1. `handler.run_for_feature(feature_name)` for new tests that are not on existing fork, i.e. a
85+
/// new handler. This will be temporary and the test will need to be updated to use
86+
/// `handle.run()` once the feature is incorporated into a fork.
87+
/// 2. `handler.run()` for tests that are already on existing forks, but with new test vectors for
88+
/// the feature. In this case the `handler.is_enabled_for_feature` will need to be implemented
89+
/// to return `true` for the feature in order for the feature test vector to be tested.
90+
#[derive(Debug, PartialEq, Clone, Copy)]
7891
pub enum FeatureName {
7992
Eip7594,
8093
}
8194

95+
impl FeatureName {
96+
pub fn list_all() -> Vec<FeatureName> {
97+
vec![FeatureName::Eip7594]
98+
}
99+
100+
/// `ForkName` to use when running the feature tests.
101+
pub fn fork_name(&self) -> ForkName {
102+
match self {
103+
FeatureName::Eip7594 => ForkName::Deneb,
104+
}
105+
}
106+
}
107+
82108
impl Display for FeatureName {
83109
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
84110
match self {
@@ -107,11 +133,13 @@ pub trait Case: Debug + Sync {
107133
true
108134
}
109135

110-
/// Whether or not this test exists for the given `feature_name`.
136+
/// Whether or not this test exists for the given `feature_name`. This is intended to be used
137+
/// for features that have not been added to a fork yet, and there is usually a separate folder
138+
/// for the feature in the `consensus-spec-tests` repository.
111139
///
112-
/// Returns `true` by default.
140+
/// Returns `false` by default.
113141
fn is_enabled_for_feature(_feature_name: FeatureName) -> bool {
114-
true
142+
false
115143
}
116144

117145
/// Execute a test and return the result.

testing/ef_tests/src/cases/get_custody_columns.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ impl<E: EthSpec> LoadCase for GetCustodyColumns<E> {
2121
}
2222

2323
impl<E: EthSpec> Case for GetCustodyColumns<E> {
24+
fn is_enabled_for_fork(_fork_name: ForkName) -> bool {
25+
false
26+
}
27+
28+
fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
29+
feature_name == FeatureName::Eip7594
30+
}
31+
2432
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
2533
let spec = E::default_spec();
2634
let node_id = U256::from_str_radix(&self.node_id, 10)
@@ -33,6 +41,7 @@ impl<E: EthSpec> Case for GetCustodyColumns<E> {
3341
)
3442
.expect("should compute custody columns")
3543
.collect::<Vec<_>>();
44+
3645
let expected = &self.result;
3746
if computed == *expected {
3847
Ok(())

testing/ef_tests/src/cases/kzg_blob_to_kzg_commitment.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ impl<E: EthSpec> Case for KZGBlobToKZGCommitment<E> {
3131
fork_name == ForkName::Deneb
3232
}
3333

34-
fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
35-
feature_name != FeatureName::Eip7594
36-
}
37-
3834
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
3935
let kzg = get_kzg();
4036
let commitment = parse_blob::<E>(&self.input.blob).and_then(|blob| {

testing/ef_tests/src/cases/kzg_compute_blob_kzg_proof.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ impl<E: EthSpec> Case for KZGComputeBlobKZGProof<E> {
3232
fork_name == ForkName::Deneb
3333
}
3434

35-
fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
36-
feature_name != FeatureName::Eip7594
37-
}
38-
3935
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
4036
let parse_input = |input: &KZGComputeBlobKZGProofInput| -> Result<_, Error> {
4137
let blob = parse_blob::<E>(&input.blob)?;

testing/ef_tests/src/cases/kzg_compute_cells_and_kzg_proofs.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ impl<E: EthSpec> LoadCase for KZGComputeCellsAndKZGProofs<E> {
2626
}
2727

2828
impl<E: EthSpec> Case for KZGComputeCellsAndKZGProofs<E> {
29-
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
30-
fork_name == ForkName::Deneb
29+
fn is_enabled_for_fork(_fork_name: ForkName) -> bool {
30+
false
31+
}
32+
33+
fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
34+
feature_name == FeatureName::Eip7594
3135
}
3236

3337
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {

testing/ef_tests/src/cases/kzg_compute_kzg_proof.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ impl<E: EthSpec> Case for KZGComputeKZGProof<E> {
3939
fork_name == ForkName::Deneb
4040
}
4141

42-
fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
43-
feature_name != FeatureName::Eip7594
44-
}
45-
4642
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
4743
let parse_input = |input: &KZGComputeKZGProofInput| -> Result<_, Error> {
4844
let blob = parse_blob::<E>(&input.blob)?;

testing/ef_tests/src/cases/kzg_recover_cells_and_kzg_proofs.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ impl<E: EthSpec> LoadCase for KZGRecoverCellsAndKZGProofs<E> {
2727
}
2828

2929
impl<E: EthSpec> Case for KZGRecoverCellsAndKZGProofs<E> {
30-
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
31-
fork_name == ForkName::Deneb
30+
fn is_enabled_for_fork(_fork_name: ForkName) -> bool {
31+
false
32+
}
33+
34+
fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
35+
feature_name == FeatureName::Eip7594
3236
}
3337

3438
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {

testing/ef_tests/src/cases/kzg_verify_blob_kzg_proof.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,6 @@ impl<E: EthSpec> Case for KZGVerifyBlobKZGProof<E> {
116116
fork_name == ForkName::Deneb
117117
}
118118

119-
fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
120-
feature_name != FeatureName::Eip7594
121-
}
122-
123119
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
124120
let parse_input = |input: &KZGVerifyBlobKZGProofInput| -> Result<(Blob<E>, KzgCommitment, KzgProof), Error> {
125121
let blob = parse_blob::<E>(&input.blob)?;

testing/ef_tests/src/cases/kzg_verify_blob_kzg_proof_batch.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ impl<E: EthSpec> Case for KZGVerifyBlobKZGProofBatch<E> {
3333
fork_name == ForkName::Deneb
3434
}
3535

36-
fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
37-
feature_name != FeatureName::Eip7594
38-
}
39-
4036
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
4137
let parse_input = |input: &KZGVerifyBlobKZGProofBatchInput| -> Result<_, Error> {
4238
let blobs = input

testing/ef_tests/src/cases/kzg_verify_cell_kzg_proof_batch.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ impl<E: EthSpec> LoadCase for KZGVerifyCellKZGProofBatch<E> {
2929
}
3030

3131
impl<E: EthSpec> Case for KZGVerifyCellKZGProofBatch<E> {
32-
fn is_enabled_for_fork(fork_name: ForkName) -> bool {
33-
fork_name == ForkName::Deneb
32+
fn is_enabled_for_fork(_fork_name: ForkName) -> bool {
33+
false
34+
}
35+
36+
fn is_enabled_for_feature(feature_name: FeatureName) -> bool {
37+
feature_name == FeatureName::Eip7594
3438
}
3539

3640
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {

0 commit comments

Comments
 (0)