use super::*; use crate::case_result::compare_beacon_state_results_without_caches; use serde_derive::Deserialize; use state_processing::per_block_processing::process_proposer_slashings; use types::{BeaconState, EthSpec, ProposerSlashing}; #[derive(Debug, Clone, Deserialize)] pub struct OperationsProposerSlashing { pub description: String, #[serde(bound = "E: EthSpec")] pub pre: BeaconState, pub proposer_slashing: ProposerSlashing, #[serde(bound = "E: EthSpec")] pub post: Option>, } impl YamlDecode for OperationsProposerSlashing { fn yaml_decode(yaml: &str) -> Result { Ok(serde_yaml::from_str(yaml).unwrap()) } } impl Case for OperationsProposerSlashing { fn description(&self) -> String { self.description.clone() } fn result(&self, _case_index: usize) -> Result<(), Error> { let mut state = self.pre.clone(); let proposer_slashing = self.proposer_slashing.clone(); let mut expected = self.post.clone(); // Processing requires the epoch cache. state.build_all_caches(&E::default_spec()).unwrap(); let result = process_proposer_slashings(&mut state, &[proposer_slashing], &E::default_spec()); let mut result = result.and_then(|_| Ok(state)); compare_beacon_state_results_without_caches(&mut result, &mut expected) } }