2019-05-14 01:13:28 +00:00
|
|
|
use super::*;
|
2019-09-03 06:46:10 +00:00
|
|
|
use rayon::prelude::*;
|
2019-05-22 06:15:52 +00:00
|
|
|
use std::fmt::Debug;
|
2019-09-05 00:19:52 +00:00
|
|
|
use std::path::{Path, PathBuf};
|
2019-05-14 01:13:28 +00:00
|
|
|
|
2019-05-21 00:32:14 +00:00
|
|
|
mod bls_aggregate_pubkeys;
|
|
|
|
mod bls_aggregate_sigs;
|
2019-05-21 02:46:22 +00:00
|
|
|
mod bls_g2_compressed;
|
|
|
|
mod bls_g2_uncompressed;
|
|
|
|
mod bls_priv_to_pub;
|
|
|
|
mod bls_sign_msg;
|
2019-09-04 03:03:44 +00:00
|
|
|
mod common;
|
2019-08-30 03:29:26 +00:00
|
|
|
mod epoch_processing;
|
2019-07-30 07:02:38 +00:00
|
|
|
mod genesis_initialization;
|
|
|
|
mod genesis_validity;
|
2019-08-30 06:16:38 +00:00
|
|
|
mod operations;
|
2019-06-11 08:05:44 +00:00
|
|
|
mod sanity_blocks;
|
2019-06-04 06:35:33 +00:00
|
|
|
mod sanity_slots;
|
2019-05-23 13:22:54 +00:00
|
|
|
mod shuffling;
|
2019-05-14 01:13:28 +00:00
|
|
|
mod ssz_generic;
|
2019-05-14 05:08:42 +00:00
|
|
|
mod ssz_static;
|
2019-05-14 01:13:28 +00:00
|
|
|
|
2019-05-21 00:32:14 +00:00
|
|
|
pub use bls_aggregate_pubkeys::*;
|
|
|
|
pub use bls_aggregate_sigs::*;
|
2019-05-21 02:46:22 +00:00
|
|
|
pub use bls_g2_compressed::*;
|
|
|
|
pub use bls_g2_uncompressed::*;
|
|
|
|
pub use bls_priv_to_pub::*;
|
|
|
|
pub use bls_sign_msg::*;
|
2019-09-04 03:03:44 +00:00
|
|
|
pub use common::SszStaticType;
|
2019-08-30 03:29:26 +00:00
|
|
|
pub use epoch_processing::*;
|
2019-07-30 07:02:38 +00:00
|
|
|
pub use genesis_initialization::*;
|
|
|
|
pub use genesis_validity::*;
|
2019-08-30 06:16:38 +00:00
|
|
|
pub use operations::*;
|
2019-06-11 08:05:44 +00:00
|
|
|
pub use sanity_blocks::*;
|
2019-06-04 06:35:33 +00:00
|
|
|
pub use sanity_slots::*;
|
2019-05-23 13:22:54 +00:00
|
|
|
pub use shuffling::*;
|
2019-05-14 01:13:28 +00:00
|
|
|
pub use ssz_generic::*;
|
2019-05-14 05:08:42 +00:00
|
|
|
pub use ssz_static::*;
|
2019-05-14 01:13:28 +00:00
|
|
|
|
2019-08-28 08:46:16 +00:00
|
|
|
pub trait LoadCase: Sized {
|
|
|
|
/// Load the test case from a test case directory.
|
|
|
|
fn load_from_dir(_path: &Path) -> Result<Self, Error>;
|
|
|
|
}
|
|
|
|
|
2019-09-03 06:46:10 +00:00
|
|
|
pub trait Case: Debug + Sync {
|
2019-05-23 06:55:50 +00:00
|
|
|
/// An optional field for implementing a custom description.
|
|
|
|
///
|
|
|
|
/// Defaults to "no description".
|
|
|
|
fn description(&self) -> String {
|
|
|
|
"no description".to_string()
|
|
|
|
}
|
|
|
|
|
2019-05-22 08:13:22 +00:00
|
|
|
/// 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>;
|
2019-05-22 06:15:52 +00:00
|
|
|
}
|
|
|
|
|
2019-05-15 01:45:50 +00:00
|
|
|
#[derive(Debug)]
|
2019-05-15 01:17:32 +00:00
|
|
|
pub struct Cases<T> {
|
2019-09-05 00:19:52 +00:00
|
|
|
pub test_cases: Vec<(PathBuf, T)>,
|
2019-05-14 01:13:28 +00:00
|
|
|
}
|
2019-05-14 05:08:42 +00:00
|
|
|
|
2019-09-03 06:46:10 +00:00
|
|
|
impl<T: Case> Cases<T> {
|
|
|
|
pub fn test_results(&self) -> Vec<CaseResult> {
|
2019-05-22 06:15:52 +00:00
|
|
|
self.test_cases
|
2019-09-03 06:46:10 +00:00
|
|
|
.into_par_iter()
|
2019-05-22 06:15:52 +00:00
|
|
|
.enumerate()
|
2019-09-05 00:19:52 +00:00
|
|
|
.map(|(i, (ref path, ref tc))| CaseResult::new(i, path, tc, tc.result(i)))
|
2019-05-22 06:15:52 +00:00
|
|
|
.collect()
|
|
|
|
}
|
|
|
|
}
|