2019-03-15 02:32:23 +00:00
|
|
|
use serde_derive::Deserialize;
|
|
|
|
use types::*;
|
2019-03-25 07:02:37 +00:00
|
|
|
#[allow(unused_imports)]
|
|
|
|
use yaml_utils;
|
2019-03-15 02:32:23 +00:00
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
|
|
pub struct TestCase {
|
|
|
|
pub name: String,
|
|
|
|
pub config: ChainSpec,
|
|
|
|
pub verify_signatures: bool,
|
|
|
|
pub initial_state: BeaconState,
|
|
|
|
pub blocks: Vec<BeaconBlock>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
|
|
pub struct TestDoc {
|
|
|
|
pub title: String,
|
|
|
|
pub summary: String,
|
|
|
|
pub fork: String,
|
|
|
|
pub test_cases: Vec<TestCase>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn yaml() {
|
|
|
|
use serde_yaml;
|
|
|
|
use std::{fs::File, io::prelude::*, path::PathBuf};
|
|
|
|
|
2019-03-25 07:02:37 +00:00
|
|
|
// Test sanity-check_small-config_32-vals.yaml
|
2019-03-15 02:32:23 +00:00
|
|
|
let mut file = {
|
|
|
|
let mut file_path_buf = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
2019-03-25 07:02:37 +00:00
|
|
|
file_path_buf.push("yaml_utils/specs/sanity-check_small-config_32-vals.yaml");
|
2019-03-15 02:32:23 +00:00
|
|
|
|
|
|
|
File::open(file_path_buf).unwrap()
|
|
|
|
};
|
|
|
|
|
|
|
|
let mut yaml_str = String::new();
|
|
|
|
|
|
|
|
file.read_to_string(&mut yaml_str).unwrap();
|
|
|
|
|
2019-03-25 07:02:37 +00:00
|
|
|
yaml_str = yaml_str.to_lowercase();
|
|
|
|
|
|
|
|
let _doc: TestDoc = serde_yaml::from_str(&yaml_str.as_str()).unwrap();
|
|
|
|
|
|
|
|
// Test sanity-check_default-config_100-vals.yaml
|
|
|
|
file = {
|
|
|
|
let mut file_path_buf = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
|
|
|
file_path_buf.push("yaml_utils/specs/sanity-check_default-config_100-vals.yaml");
|
|
|
|
|
|
|
|
File::open(file_path_buf).unwrap()
|
|
|
|
};
|
|
|
|
|
|
|
|
yaml_str = String::new();
|
|
|
|
|
|
|
|
file.read_to_string(&mut yaml_str).unwrap();
|
|
|
|
|
|
|
|
yaml_str = yaml_str.to_lowercase();
|
2019-03-15 02:32:23 +00:00
|
|
|
|
|
|
|
let _doc: TestDoc = serde_yaml::from_str(&yaml_str.as_str()).unwrap();
|
|
|
|
}
|