diff --git a/tests/ef_tests/src/cases.rs b/tests/ef_tests/src/cases.rs index 392a201df..8f90d9589 100644 --- a/tests/ef_tests/src/cases.rs +++ b/tests/ef_tests/src/cases.rs @@ -22,7 +22,11 @@ pub use ssz_generic::*; pub use ssz_static::*; pub trait Case { - fn result(&self) -> Result<(), Error>; + /// 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 + /// necessary, but it's useful when troubleshooting specific failing tests. + fn result(&self, case_index: usize) -> Result<(), Error>; } #[derive(Debug)] @@ -38,7 +42,7 @@ where self.test_cases .iter() .enumerate() - .map(|(i, tc)| CaseResult::new(i, tc, tc.result())) + .map(|(i, tc)| CaseResult::new(i, tc, tc.result(i))) .collect() } } diff --git a/tests/ef_tests/src/cases/bls_aggregate_pubkeys.rs b/tests/ef_tests/src/cases/bls_aggregate_pubkeys.rs index 846421da0..6cd37ec36 100644 --- a/tests/ef_tests/src/cases/bls_aggregate_pubkeys.rs +++ b/tests/ef_tests/src/cases/bls_aggregate_pubkeys.rs @@ -16,7 +16,7 @@ impl YamlDecode for BlsAggregatePubkeys { } impl Case for BlsAggregatePubkeys { - fn result(&self) -> Result<(), Error> { + fn result(&self, _case_index: usize) -> Result<(), Error> { let mut aggregate_pubkey = AggregatePublicKey::new(); for key_str in &self.input { diff --git a/tests/ef_tests/src/cases/bls_aggregate_sigs.rs b/tests/ef_tests/src/cases/bls_aggregate_sigs.rs index 1f3b437c3..5b69a6134 100644 --- a/tests/ef_tests/src/cases/bls_aggregate_sigs.rs +++ b/tests/ef_tests/src/cases/bls_aggregate_sigs.rs @@ -16,7 +16,7 @@ impl YamlDecode for BlsAggregateSigs { } impl Case for BlsAggregateSigs { - fn result(&self) -> Result<(), Error> { + fn result(&self, _case_index: usize) -> Result<(), Error> { let mut aggregate_signature = AggregateSignature::new(); for key_str in &self.input { diff --git a/tests/ef_tests/src/cases/bls_g2_compressed.rs b/tests/ef_tests/src/cases/bls_g2_compressed.rs index 165c29e69..e6895ca1a 100644 --- a/tests/ef_tests/src/cases/bls_g2_compressed.rs +++ b/tests/ef_tests/src/cases/bls_g2_compressed.rs @@ -22,7 +22,7 @@ impl YamlDecode for BlsG2Compressed { } impl Case for BlsG2Compressed { - fn result(&self) -> Result<(), Error> { + fn result(&self, _case_index: usize) -> Result<(), Error> { // Convert message and domain to required types let msg = hex::decode(&self.input.message[2..]) .map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?; diff --git a/tests/ef_tests/src/cases/bls_g2_uncompressed.rs b/tests/ef_tests/src/cases/bls_g2_uncompressed.rs index d4cec3e00..93b1e1c51 100644 --- a/tests/ef_tests/src/cases/bls_g2_uncompressed.rs +++ b/tests/ef_tests/src/cases/bls_g2_uncompressed.rs @@ -22,7 +22,7 @@ impl YamlDecode for BlsG2Uncompressed { } impl Case for BlsG2Uncompressed { - fn result(&self) -> Result<(), Error> { + fn result(&self, _case_index: usize) -> Result<(), Error> { // Convert message and domain to required types let msg = hex::decode(&self.input.message[2..]) .map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?; diff --git a/tests/ef_tests/src/cases/bls_priv_to_pub.rs b/tests/ef_tests/src/cases/bls_priv_to_pub.rs index f7773a3bc..c558d0142 100644 --- a/tests/ef_tests/src/cases/bls_priv_to_pub.rs +++ b/tests/ef_tests/src/cases/bls_priv_to_pub.rs @@ -16,7 +16,7 @@ impl YamlDecode for BlsPrivToPub { } impl Case for BlsPrivToPub { - fn result(&self) -> Result<(), Error> { + fn result(&self, _case_index: usize) -> Result<(), Error> { let secret = &self.input; // Convert message and domain to required types diff --git a/tests/ef_tests/src/cases/bls_sign_msg.rs b/tests/ef_tests/src/cases/bls_sign_msg.rs index ba9bc77a9..a361f2523 100644 --- a/tests/ef_tests/src/cases/bls_sign_msg.rs +++ b/tests/ef_tests/src/cases/bls_sign_msg.rs @@ -23,7 +23,7 @@ impl YamlDecode for BlsSign { } impl Case for BlsSign { - fn result(&self) -> Result<(), Error> { + fn result(&self, _case_index: usize) -> Result<(), Error> { // Convert private_key, message and domain to required types let mut sk = hex::decode(&self.input.privkey[2..]) .map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?; diff --git a/tests/ef_tests/src/cases/operations_deposit.rs b/tests/ef_tests/src/cases/operations_deposit.rs index 6645e28c8..150d3f0f7 100644 --- a/tests/ef_tests/src/cases/operations_deposit.rs +++ b/tests/ef_tests/src/cases/operations_deposit.rs @@ -21,13 +21,14 @@ impl YamlDecode for OperationsDeposit { } impl Case for OperationsDeposit { - fn result(&self) -> Result<(), Error> { + fn result(&self, _case_index: usize) -> Result<(), Error> { let mut state = self.pre.clone(); let deposit = self.deposit.clone(); let mut expected = self.post.clone(); - let mut result = - process_deposits(&mut state, &[deposit], &E::spec()).and_then(|_| Ok(state)); + let result = process_deposits(&mut state, &[deposit], &E::spec()); + + let mut result = result.and_then(|_| Ok(state)); compare_beacon_state_results_without_caches(&mut result, &mut expected) } diff --git a/tests/ef_tests/src/cases/ssz_generic.rs b/tests/ef_tests/src/cases/ssz_generic.rs index b270d7b23..09aba39f1 100644 --- a/tests/ef_tests/src/cases/ssz_generic.rs +++ b/tests/ef_tests/src/cases/ssz_generic.rs @@ -21,7 +21,7 @@ impl YamlDecode for SszGeneric { } impl Case for SszGeneric { - fn result(&self) -> Result<(), Error> { + fn result(&self, _case_index: usize) -> Result<(), Error> { if let Some(ssz) = &self.ssz { match self.type_name.as_ref() { "uint8" => ssz_generic_test::(self.valid, ssz, &self.value), diff --git a/tests/ef_tests/src/cases/ssz_static.rs b/tests/ef_tests/src/cases/ssz_static.rs index 3bd236bbd..bef29a399 100644 --- a/tests/ef_tests/src/cases/ssz_static.rs +++ b/tests/ef_tests/src/cases/ssz_static.rs @@ -51,7 +51,7 @@ impl SszStatic { } impl Case for SszStatic { - fn result(&self) -> Result<(), Error> { + fn result(&self, _case_index: usize) -> Result<(), Error> { match self.type_name.as_ref() { "Fork" => ssz_static_test::(self), "Crosslink" => ssz_static_test::(self), diff --git a/tests/ef_tests/tests/tests.rs b/tests/ef_tests/tests/tests.rs index 8c9ae8d7d..2482d67f8 100644 --- a/tests/ef_tests/tests/tests.rs +++ b/tests/ef_tests/tests/tests.rs @@ -52,11 +52,12 @@ fn ssz_static() { } #[test] -#[cfg(feature = "fake_crypto")] +#[cfg(not(feature = "fake_crypto"))] fn operations_deposit() { yaml_files_in_test_dir(&Path::new("operations").join("deposit")) // .into_par_iter() .into_iter() + .rev() .for_each(|file| { Doc::assert_tests_pass(file); });