Skip to content

Commit

Permalink
Hide custom FC tests behind flag, disable standard tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhauner committed Feb 9, 2023
1 parent 0b56a73 commit b175574
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 38 deletions.
1 change: 1 addition & 0 deletions testing/ef_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ edition = "2021"
ef_tests = []
milagro = ["bls/milagro"]
fake_crypto = ["bls/fake_crypto"]
fork_choice_custom = []

[dependencies]
bls = { path = "../../crypto/bls", default-features = false }
Expand Down
82 changes: 44 additions & 38 deletions testing/ef_tests/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
use ef_tests::*;
use types::*;

const CONSENSUS_SPEC_TESTS: &str = "consensus-spec-tests";
const CUSTOM_FC_TESTS: &str = "custom-fc-tests";

// Check that the hand-computed multiplications on EthSpec are correctly computed.
// This test lives here because one is most likely to muck these up during a spec update.
fn check_typenum_values<E: EthSpec>() {
Expand Down Expand Up @@ -427,51 +424,60 @@ fn finality() {
FinalityHandler::<MainnetEthSpec>::default().run();
}

#[allow(unused_macros)] // TODO(paul): remove `allow` once we have EF test release.
macro_rules! fork_choice_tests {
($mod: ident, $tests_dir: ident) => {
mod $mod {
use super::*;

#[test]
fn fork_choice_get_head() {
ForkChoiceHandler::<MinimalEthSpec>::new($tests_dir, "get_head").run();
ForkChoiceHandler::<MainnetEthSpec>::new($tests_dir, "get_head").run();
}
($tests_dir: ident) => {
#[test]
fn fork_choice_get_head() {
ForkChoiceHandler::<MinimalEthSpec>::new($tests_dir, "get_head").run();
ForkChoiceHandler::<MainnetEthSpec>::new($tests_dir, "get_head").run();
}

#[test]
fn fork_choice_on_block() {
ForkChoiceHandler::<MinimalEthSpec>::new($tests_dir, "on_block").run();
ForkChoiceHandler::<MainnetEthSpec>::new($tests_dir, "on_block").run();
}
#[test]
fn fork_choice_on_block() {
ForkChoiceHandler::<MinimalEthSpec>::new($tests_dir, "on_block").run();
ForkChoiceHandler::<MainnetEthSpec>::new($tests_dir, "on_block").run();
}

#[test]
fn fork_choice_on_merge_block() {
ForkChoiceHandler::<MinimalEthSpec>::new($tests_dir, "on_merge_block").run();
ForkChoiceHandler::<MainnetEthSpec>::new($tests_dir, "on_merge_block").run();
}
#[test]
fn fork_choice_on_merge_block() {
ForkChoiceHandler::<MinimalEthSpec>::new($tests_dir, "on_merge_block").run();
ForkChoiceHandler::<MainnetEthSpec>::new($tests_dir, "on_merge_block").run();
}

#[test]
fn fork_choice_ex_ante() {
ForkChoiceHandler::<MinimalEthSpec>::new($tests_dir, "ex_ante").run();
ForkChoiceHandler::<MainnetEthSpec>::new($tests_dir, "ex_ante").run();
}
#[test]
fn fork_choice_ex_ante() {
ForkChoiceHandler::<MinimalEthSpec>::new($tests_dir, "ex_ante").run();
ForkChoiceHandler::<MainnetEthSpec>::new($tests_dir, "ex_ante").run();
}
};
}

fork_choice_tests!(fork_choice_standard, CONSENSUS_SPEC_TESTS);
fork_choice_tests!(fork_choice_custom, CUSTOM_FC_TESTS);
// TODO(paul): The typical fork choice tests from the latest release will not
// pass due to the changes in PR #18. This must be resolved before we merge into
// `unstable`, but we are waiting on new test vectors from the EF.
//
// fork_choice_tests!("consensus_spec_tests");

#[test]
fn fork_choice_custom_reorg() {
ForkChoiceHandler::<MinimalEthSpec>::new(CUSTOM_FC_TESTS, "reorg").run();
ForkChoiceHandler::<MainnetEthSpec>::new(CUSTOM_FC_TESTS, "reorg").run();
}
#[cfg(feature = "fork_choice_custom")]
mod fork_choice_custom {
use super::*;

#[test]
fn fork_choice_custom_withholding() {
ForkChoiceHandler::<MinimalEthSpec>::new(CUSTOM_FC_TESTS, "withholding").run();
ForkChoiceHandler::<MainnetEthSpec>::new(CUSTOM_FC_TESTS, "withholding").run();
const CUSTOM_FC_TESTS: &str = "custom-fc-tests";

fork_choice_tests!(CUSTOM_FC_TESTS);

#[test]
fn fork_choice_custom_reorg() {
ForkChoiceHandler::<MinimalEthSpec>::new(CUSTOM_FC_TESTS, "reorg").run();
ForkChoiceHandler::<MainnetEthSpec>::new(CUSTOM_FC_TESTS, "reorg").run();
}

#[test]
fn fork_choice_custom_withholding() {
ForkChoiceHandler::<MinimalEthSpec>::new(CUSTOM_FC_TESTS, "withholding").run();
ForkChoiceHandler::<MainnetEthSpec>::new(CUSTOM_FC_TESTS, "withholding").run();
}
}

#[test]
Expand Down

0 comments on commit b175574

Please sign in to comment.