Enable operations tests, start testing

This commit is contained in:
Paul Hauner 2019-05-22 16:46:50 +10:00
parent 2cffca7b1a
commit 30d582f40d
No known key found for this signature in database
GPG Key ID: 5E2CFF9B75FA63DF
3 changed files with 24 additions and 20 deletions

View File

@ -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<T: Debug>(val: T) -> String {
let mut string = format!("{:?}", val);
string.truncate(MAX_VALUE_STRING_LEN);
string
}

View File

@ -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<E: EthSpec> YamlDecode for OperationsDeposit<E> {
}
}
/*
impl<T: EthSpec> EfTest for Cases<OperationsDeposit<T>> {
fn test_results<E: EthSpec>(&self) -> Vec<CaseResult> {
self.test_cases
.iter()
.enumerate()
.map(|(i, tc)| {
// TODO: run test
let result = Ok(());
impl<E: EthSpec> Case for OperationsDeposit<E> {
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)
}
}
*/

View File

@ -51,14 +51,12 @@ impl Doc {
("bls", "msg_hash_uncompressed", "mainnet") => vec![],
("bls", "priv_to_pub", "mainnet") => run_test::<BlsPrivToPub>(self),
("bls", "sign_msg", "mainnet") => run_test::<BlsSign>(self),
/*
("operations", "deposit", "mainnet") => {
run_test::<OperationsDeposit<MainnetEthSpec>>(self)
}
("operations", "deposit", "minimal") => {
run_test::<OperationsDeposit<MinimalEthSpec>>(self)
}
*/
(runner, handler, config) => panic!(
"No implementation for runner: \"{}\", handler: \"{}\", config: \"{}\"",
runner, handler, config