Merge branch 'ef-tests' of github.com:sigp/lighthouse into ef-tests
This commit is contained in:
commit
068b6fafde
@ -1,8 +1,8 @@
|
|||||||
use error::Error;
|
use error::Error;
|
||||||
|
use ethereum_types::{U128, U256};
|
||||||
use serde_derive::Deserialize;
|
use serde_derive::Deserialize;
|
||||||
use ssz::Decode;
|
use ssz::Decode;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use ethereum_types::{U256, U128};
|
|
||||||
use test_decode::TestDecode;
|
use test_decode::TestDecode;
|
||||||
|
|
||||||
mod error;
|
mod error;
|
||||||
@ -35,8 +35,7 @@ pub trait Test {
|
|||||||
|
|
||||||
impl Test for TestDoc<SszGenericCase> {
|
impl Test for TestDoc<SszGenericCase> {
|
||||||
fn test(&self) -> Vec<Result<(), Error>> {
|
fn test(&self) -> Vec<Result<(), Error>> {
|
||||||
self
|
self.test_cases
|
||||||
.test_cases
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|tc| {
|
.map(|tc| {
|
||||||
if let Some(ssz) = &tc.ssz {
|
if let Some(ssz) = &tc.ssz {
|
||||||
@ -47,9 +46,10 @@ impl Test for TestDoc<SszGenericCase> {
|
|||||||
"uint64" => compare_decoding::<u64>(tc.valid, ssz, &tc.value),
|
"uint64" => compare_decoding::<u64>(tc.valid, ssz, &tc.value),
|
||||||
"uint128" => compare_decoding::<U128>(tc.valid, ssz, &tc.value),
|
"uint128" => compare_decoding::<U128>(tc.valid, ssz, &tc.value),
|
||||||
"uint256" => compare_decoding::<U256>(tc.valid, ssz, &tc.value),
|
"uint256" => compare_decoding::<U256>(tc.valid, ssz, &tc.value),
|
||||||
_ => {
|
_ => Err(Error::FailedToParseTest(format!(
|
||||||
Err(Error::FailedToParseTest(format!("Unknown type: {}", tc.type_name)))
|
"Unknown type: {}",
|
||||||
}
|
tc.type_name
|
||||||
|
))),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Skip tests that do not have an ssz field.
|
// Skip tests that do not have an ssz field.
|
||||||
@ -66,8 +66,7 @@ fn compare_decoding<T>(should_pass: bool, ssz: &String, value: &String) -> Resul
|
|||||||
where
|
where
|
||||||
T: Decode + TestDecode + Debug + PartialEq<T>,
|
T: Decode + TestDecode + Debug + PartialEq<T>,
|
||||||
{
|
{
|
||||||
let ssz = hex::decode(&ssz[2..])
|
let ssz = hex::decode(&ssz[2..]).map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?;
|
||||||
.map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?;
|
|
||||||
let expected = T::test_decode(value)?;
|
let expected = T::test_decode(value)?;
|
||||||
|
|
||||||
let decoded = T::from_ssz_bytes(&ssz);
|
let decoded = T::from_ssz_bytes(&ssz);
|
||||||
|
@ -26,7 +26,7 @@ fn ssz() {
|
|||||||
let failures: Vec<(usize, &Result<_, _>)> = results
|
let failures: Vec<(usize, &Result<_, _>)> = results
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter(|(_i, r)| r.is_ok())
|
.filter(|(_i, r)| r.is_err())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
if !failures.is_empty() {
|
if !failures.is_empty() {
|
||||||
|
Loading…
Reference in New Issue
Block a user