diff --git a/eth2/types/src/beacon_state/tests.rs b/eth2/types/src/beacon_state/tests.rs index fd3ba25aa..588d24aa8 100644 --- a/eth2/types/src/beacon_state/tests.rs +++ b/eth2/types/src/beacon_state/tests.rs @@ -153,7 +153,7 @@ fn test_cache_initialization<'a, T: EthSpec>( .unwrap(); // Drop the cache. - state.drop_cache(relative_epoch); + state.drop_committee_cache(relative_epoch); // Assert a call to a cache-using function fail. assert_eq!( diff --git a/tests/ef_tests/src/case_result.rs b/tests/ef_tests/src/case_result.rs index 613b82734..c61874e3a 100644 --- a/tests/ef_tests/src/case_result.rs +++ b/tests/ef_tests/src/case_result.rs @@ -13,10 +13,10 @@ pub struct CaseResult { } impl CaseResult { - pub fn new(case_index: usize, case: &T, result: Result<(), Error>) -> Self { + pub fn new(case_index: usize, case: &impl Case, result: Result<(), Error>) -> Self { CaseResult { case_index, - desc: format!("{:?}", case), + desc: case.description(), result, } } @@ -60,7 +60,7 @@ where if !mismatching_fields.is_empty() { Err(Error::NotEqual(format!( - "Fields not equal: {:#?}", + "Fields not equal (a = expected, b = result): {:#?}", mismatching_fields ))) } else { diff --git a/tests/ef_tests/src/cases.rs b/tests/ef_tests/src/cases.rs index f3432bc1b..511759875 100644 --- a/tests/ef_tests/src/cases.rs +++ b/tests/ef_tests/src/cases.rs @@ -25,7 +25,14 @@ pub use operations_transfer::*; pub use ssz_generic::*; pub use ssz_static::*; -pub trait Case { +pub trait Case: Debug { + /// An optional field for implementing a custom description. + /// + /// Defaults to "no description". + fn description(&self) -> String { + "no description".to_string() + } + /// Execute a test and return the result. /// /// `case_index` reports the index of the case in the set of test cases. It is not strictly diff --git a/tests/ef_tests/src/cases/operations_deposit.rs b/tests/ef_tests/src/cases/operations_deposit.rs index 150d3f0f7..1d0b43af9 100644 --- a/tests/ef_tests/src/cases/operations_deposit.rs +++ b/tests/ef_tests/src/cases/operations_deposit.rs @@ -21,6 +21,10 @@ impl YamlDecode for OperationsDeposit { } impl Case for OperationsDeposit { + fn description(&self) -> String { + self.description.clone() + } + fn result(&self, _case_index: usize) -> Result<(), Error> { let mut state = self.pre.clone(); let deposit = self.deposit.clone(); diff --git a/tests/ef_tests/src/cases/operations_exit.rs b/tests/ef_tests/src/cases/operations_exit.rs index 8df5343fa..3d0f6b010 100644 --- a/tests/ef_tests/src/cases/operations_exit.rs +++ b/tests/ef_tests/src/cases/operations_exit.rs @@ -21,12 +21,16 @@ impl YamlDecode for OperationsExit { } impl Case for OperationsExit { + fn description(&self) -> String { + self.description.clone() + } + fn result(&self, _case_index: usize) -> Result<(), Error> { let mut state = self.pre.clone(); let exit = self.voluntary_exit.clone(); let mut expected = self.post.clone(); - // Epoch processing requires the epoch cache. + // Exit processing requires the epoch cache. state.build_all_caches(&E::spec()).unwrap(); let result = process_exits(&mut state, &[exit], &E::spec()); diff --git a/tests/ef_tests/src/cases/operations_transfer.rs b/tests/ef_tests/src/cases/operations_transfer.rs index 10961e2c2..3ec96cd5c 100644 --- a/tests/ef_tests/src/cases/operations_transfer.rs +++ b/tests/ef_tests/src/cases/operations_transfer.rs @@ -21,12 +21,22 @@ impl YamlDecode for OperationsTransfer { } impl Case for OperationsTransfer { + fn description(&self) -> String { + self.description.clone() + } + fn result(&self, _case_index: usize) -> Result<(), Error> { let mut state = self.pre.clone(); let transfer = self.transfer.clone(); let mut expected = self.post.clone(); - let result = process_transfers(&mut state, &[transfer], &E::spec()); + // Transfer processing requires the epoch cache. + state.build_all_caches(&E::spec()).unwrap(); + + let mut spec = E::spec(); + spec.max_transfers = 1; + + let result = process_transfers(&mut state, &[transfer], &spec); let mut result = result.and_then(|_| Ok(state)); diff --git a/tests/ef_tests/src/doc.rs b/tests/ef_tests/src/doc.rs index 543a120a0..686173df3 100644 --- a/tests/ef_tests/src/doc.rs +++ b/tests/ef_tests/src/doc.rs @@ -123,7 +123,12 @@ pub fn print_failures(doc: &Doc, results: &[CaseResult]) { let error = failure.result.clone().unwrap_err(); println!("-------"); - println!("case[{}] failed with {}:", failure.case_index, error.name()); + println!( + "case[{}] ({}) failed with {}:", + failure.case_index, + failure.desc, + error.name() + ); println!("{}", error.message()); } println!(""); diff --git a/tests/ef_tests/src/lib.rs b/tests/ef_tests/src/lib.rs index 8806acc94..942a6dbb7 100644 --- a/tests/ef_tests/src/lib.rs +++ b/tests/ef_tests/src/lib.rs @@ -1,6 +1,7 @@ use types::EthSpec; pub use case_result::CaseResult; +pub use cases::Case; pub use doc::Doc; pub use error::Error; pub use yaml_decode::YamlDecode; diff --git a/tests/ef_tests/tests/tests.rs b/tests/ef_tests/tests/tests.rs index c1722d731..ecfbca14a 100644 --- a/tests/ef_tests/tests/tests.rs +++ b/tests/ef_tests/tests/tests.rs @@ -33,9 +33,9 @@ fn yaml_files_in_test_dir(dir: &Path) -> Vec { }) .collect(); - // Reverse the file order. Assuming files come in lexicographical order, doing it in - // reverse means we get the "minimal" tests before the "mainnet" tests. This makes life - // easier for debugging. + // Reverse the file order. Assuming files come in lexicographical order, executing tests in + // reverse means we get the "minimal" tests before the "mainnet" tests. This makes life easier + // for debugging. paths.reverse(); paths } @@ -70,20 +70,16 @@ fn operations_deposit() { }); } -// No transfers are permitted in phase 0. -/* #[test] #[cfg(not(feature = "fake_crypto"))] fn operations_transfer() { yaml_files_in_test_dir(&Path::new("operations").join("transfer")) - // .into_par_iter() - .into_iter() + .into_par_iter() .rev() .for_each(|file| { Doc::assert_tests_pass(file); }); } -*/ #[test] #[cfg(not(feature = "fake_crypto"))]