Update ef_tests for new compare_fields API

This commit is contained in:
Paul Hauner 2019-05-24 13:57:24 +10:00
parent 99ae734638
commit 686963bd34
No known key found for this signature in database
GPG Key ID: 5E2CFF9B75FA63DF
2 changed files with 10 additions and 4 deletions

View File

@ -86,7 +86,9 @@ where
pub fork: Fork,
// Validator registry
#[compare_fields(as_slice)]
pub validator_registry: Vec<Validator>,
#[compare_fields(as_slice)]
pub balances: Vec<u64>,
// Randomness and committees

View File

@ -1,5 +1,5 @@
use super::*;
use compare_fields::{CompareFields, FieldComparison};
use compare_fields::{CompareFields, Comparison, FieldComparison};
use std::fmt::Debug;
use types::BeaconState;
@ -51,13 +51,17 @@ where
{
match (result, expected) {
(Ok(result), Some(expected)) => {
let mismatching_fields: Vec<FieldComparison> = expected
let mut mismatching_fields: Vec<Comparison> = expected
.compare_fields(result)
.into_iter()
.filter(|c| !c.equal)
// .map(|c| c.field_name)
// Filter all out all fields that are equal.
.filter(Comparison::not_equal)
.collect();
mismatching_fields
.iter_mut()
.for_each(|f| f.retain_children(FieldComparison::not_equal));
if !mismatching_fields.is_empty() {
Err(Error::NotEqual(format!(
"Fields not equal (a = expected, b = result): {:#?}",