Remove serde de-ser constraint from Cases

This commit is contained in:
Paul Hauner 2019-05-15 11:45:50 +10:00
parent 5a361b852a
commit 035e124a14
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6
2 changed files with 5 additions and 3 deletions

View File

@ -1,6 +1,5 @@
use super::*;
use crate::yaml_decode::*;
use serde_derive::Deserialize;
use yaml_rust::YamlLoader;
mod ssz_generic;
@ -9,7 +8,7 @@ mod ssz_static;
pub use ssz_generic::*;
pub use ssz_static::*;
#[derive(Debug, Deserialize)]
#[derive(Debug)]
pub struct Cases<T> {
pub test_cases: Vec<T>,
}
@ -23,6 +22,7 @@ impl<T: YamlDecode> YamlDecode for Cases<T> {
let mut i = 0;
loop {
// `is_badvalue` indicates when we have reached the end of the YAML list.
if doc[i].is_badvalue() {
break;
} else {

View File

@ -59,10 +59,12 @@ impl Doc {
pub fn run_test<T, E: EthSpec>(test_doc_yaml: &String) -> Vec<CaseResult>
where
Cases<T>: EfTest + serde::de::DeserializeOwned + YamlDecode,
Cases<T>: EfTest + YamlDecode,
{
// Extract only the "test_cases" YAML as a stand-alone string.
let test_cases_yaml = extract_yaml_by_key(test_doc_yaml, "test_cases");
// Pass only the "test_cases" YAML string to `yaml_decode`.
let test_cases: Cases<T> = Cases::yaml_decode(&test_cases_yaml.to_string()).unwrap();
test_cases.test_results::<E>()