mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 13:24:44 +00:00
Several changes
* Fix state cache pruning of finalized state from block map * Update to latest `milhouse` * Check beacon state diffs in EF tests
This commit is contained in:
@@ -2,7 +2,7 @@ use super::*;
|
||||
use compare_fields::{CompareFields, Comparison, FieldComparison};
|
||||
use std::fmt::Debug;
|
||||
use std::path::{Path, PathBuf};
|
||||
use types::BeaconState;
|
||||
use types::{beacon_state::BeaconStateDiff, milhouse::diff::Diff, BeaconState};
|
||||
|
||||
pub const MAX_VALUE_STRING_LEN: usize = 500;
|
||||
|
||||
@@ -118,6 +118,23 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check_state_diff<T: EthSpec>(
|
||||
pre_state: &BeaconState<T>,
|
||||
opt_post_state: &Option<BeaconState<T>>,
|
||||
) -> Result<(), Error> {
|
||||
if let Some(post_state) = opt_post_state {
|
||||
let diff = BeaconStateDiff::compute_diff(pre_state, post_state)
|
||||
.expect("BeaconStateDiff should compute");
|
||||
let mut diffed_state = pre_state.clone();
|
||||
diff.apply_diff(&mut diffed_state)
|
||||
.expect("BeaconStateDiff should apply");
|
||||
|
||||
compare_result_detailed::<_, ()>(&Ok(diffed_state), opt_post_state)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn fmt_val<T: Debug>(val: T) -> String {
|
||||
let mut string = format!("{:?}", val);
|
||||
string.truncate(MAX_VALUE_STRING_LEN);
|
||||
|
||||
Reference in New Issue
Block a user