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

add v1.5.0-alpha.0 spec tests #388

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
11 changes: 10 additions & 1 deletion ethereum-consensus/src/electra/presets/mainnet.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
pub use crate::electra::presets::Preset;
use crate::electra::spec;
use crate::{
electra::spec,
phase0::mainnet::{MAX_COMMITTEES_PER_SLOT, MAX_VALIDATORS_PER_COMMITTEE},
};

pub use spec::*;

Expand Down Expand Up @@ -32,3 +35,9 @@ pub const PRESET: Preset = Preset {
max_withdrawal_requests_per_payload: MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD,
max_pending_partials_per_withdrawals_sweep: MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP,
};

const MAX_VALIDATORS_PER_SLOT: usize =
MAX_COMMITTEES_PER_SLOT as usize * MAX_VALIDATORS_PER_COMMITTEE;

pub type Attestation =
spec::Attestation<MAX_VALIDATORS_PER_SLOT, { MAX_COMMITTEES_PER_SLOT as usize }>;
11 changes: 10 additions & 1 deletion ethereum-consensus/src/electra/presets/minimal.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
pub use crate::electra::presets::Preset;
use crate::electra::spec;
use crate::{
electra::spec,
phase0::minimal::{MAX_COMMITTEES_PER_SLOT, MAX_VALIDATORS_PER_COMMITTEE},
};

pub use spec::*;

Expand Down Expand Up @@ -32,3 +35,9 @@ pub const PRESET: Preset = Preset {
max_withdrawal_requests_per_payload: MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD,
max_pending_partials_per_withdrawals_sweep: MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP,
};

const MAX_VALIDATORS_PER_SLOT: usize =
MAX_COMMITTEES_PER_SLOT as usize * MAX_VALIDATORS_PER_COMMITTEE;

pub type Attestation =
spec::Attestation<MAX_VALIDATORS_PER_SLOT, { MAX_COMMITTEES_PER_SLOT as usize }>;
30 changes: 30 additions & 0 deletions spec-tests/runners/ssz_static.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,31 @@ fn run_test<T: ssz_rs::SimpleSerialize>(
Ok(())
}

macro_rules! gen_electra {
($test_case:expr, $($handler:ident),*) => {
let result = match $test_case.meta.handler.0.as_str() {
$(
stringify!($handler) => gen_match_for! {
$test_case,
(mainnet, electra),
(minimal, electra)
{
gen_exec! {
$test_case, load_test, run_test::<spec::$handler>
}
}
},
)*
_ => Err(Error::InternalContinue),
};
match result {
Ok(()) => return Ok(()),
Err(Error::InternalContinue) => {},
Err(err) => return Err(err)
}
};
}

macro_rules! gen_deneb_and_later {
($test_case:expr, $($handler:ident),*) => {
let result = match $test_case.meta.handler.0.as_str() {
Expand Down Expand Up @@ -165,6 +190,11 @@ macro_rules! gen_match {
}

pub fn dispatch(test: &TestCase) -> Result<(), Error> {
gen_electra! {
test,
Attestation
}

gen_deneb_and_later! {
test,
BlobSidecar,
Expand Down
2 changes: 1 addition & 1 deletion spec-tests/spec-test-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.4.0
v1.5.0-alpha.0
2 changes: 2 additions & 0 deletions spec-tests/test_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub enum Fork {
Bellatrix,
Capella,
Deneb,
Electra,
Eip6110,
Whisk,
}
Expand All @@ -45,6 +46,7 @@ impl From<&str> for Fork {
"bellatrix" => Self::Bellatrix,
"capella" => Self::Capella,
"deneb" => Self::Deneb,
"electra" => Self::Electra,
"eip6110" => Self::Eip6110,
"whisk" => Self::Whisk,
fork => panic!("unsupported fork: {fork:?}"),
Expand Down
Loading