diff --git a/tests/ef_tests/src/case_result.rs b/tests/ef_tests/src/case_result.rs index 7b7afd1bd..2bf9813c6 100644 --- a/tests/ef_tests/src/case_result.rs +++ b/tests/ef_tests/src/case_result.rs @@ -1,6 +1,8 @@ use super::*; use std::fmt::Debug; +pub const MAX_VALUE_STRING_LEN: usize = 500; + #[derive(Debug, PartialEq, Clone)] pub struct CaseResult { pub case_index: usize, @@ -32,21 +34,29 @@ where (Err(_), None) => Ok(()), // Fail: The test failed when it should have produced a result (fail). (Err(e), Some(expected)) => Err(Error::NotEqual(format!( - "Got {:?} Expected {:?}", - e, expected + "Got {:?} | Expected {:?}", + e, + fmt_val(expected) ))), // Fail: The test produced a result when it should have failed (fail). - (Ok(result), None) => Err(Error::DidntFail(format!("Got {:?}", result))), + (Ok(result), None) => Err(Error::DidntFail(format!("Got {:?}", fmt_val(result)))), // Potential Pass: The test should have produced a result, and it did. (Ok(result), Some(expected)) => { if result == expected { Ok(()) } else { Err(Error::NotEqual(format!( - "Got {:?} expected {:?}", - result, expected + "Got {:?} | Expected {:?}", + fmt_val(result), + fmt_val(expected) ))) } } } } + +fn fmt_val(val: T) -> String { + let mut string = format!("{:?}", val); + string.truncate(MAX_VALUE_STRING_LEN); + string +} diff --git a/tests/ef_tests/src/cases/operations_deposit.rs b/tests/ef_tests/src/cases/operations_deposit.rs index 81fd2b039..fb2364961 100644 --- a/tests/ef_tests/src/cases/operations_deposit.rs +++ b/tests/ef_tests/src/cases/operations_deposit.rs @@ -1,5 +1,7 @@ use super::*; +use crate::case_result::compare_result; use serde_derive::Deserialize; +use state_processing::per_block_processing::process_deposits; use types::{BeaconState, Deposit, EthSpec}; #[derive(Debug, Clone, Deserialize)] @@ -18,19 +20,13 @@ impl YamlDecode for OperationsDeposit { } } -/* -impl EfTest for Cases> { - fn test_results(&self) -> Vec { - self.test_cases - .iter() - .enumerate() - .map(|(i, tc)| { - // TODO: run test - let result = Ok(()); +impl Case for OperationsDeposit { + fn result(&self) -> Result<(), Error> { + let mut state = self.pre.clone(); + let deposit = self.deposit.clone(); - CaseResult::new(i, tc, result) - }) - .collect() + let result = process_deposits(&mut state, &[deposit], &E::spec()).and_then(|_| Ok(state)); + + compare_result(&result, &self.post) } } -*/ diff --git a/tests/ef_tests/src/doc.rs b/tests/ef_tests/src/doc.rs index e818c4596..c475c67c6 100644 --- a/tests/ef_tests/src/doc.rs +++ b/tests/ef_tests/src/doc.rs @@ -51,14 +51,12 @@ impl Doc { ("bls", "msg_hash_uncompressed", "mainnet") => vec![], ("bls", "priv_to_pub", "mainnet") => run_test::(self), ("bls", "sign_msg", "mainnet") => run_test::(self), - /* ("operations", "deposit", "mainnet") => { run_test::>(self) } ("operations", "deposit", "minimal") => { run_test::>(self) } - */ (runner, handler, config) => panic!( "No implementation for runner: \"{}\", handler: \"{}\", config: \"{}\"", runner, handler, config