Add proposer_slashing EF tests
This commit is contained in:
parent
31a7a0614e
commit
67f890ae48
@ -1 +1 @@
|
||||
Subproject commit 6fde1e806b340d946839d6261c63c779f0cadd81
|
||||
Subproject commit 746712e8a5c5b97d1bbc7724e5ccd09920c50a30
|
@ -9,6 +9,7 @@ mod bls_priv_to_pub;
|
||||
mod bls_sign_msg;
|
||||
mod operations_deposit;
|
||||
mod operations_exit;
|
||||
mod operations_proposer_slashing;
|
||||
mod operations_transfer;
|
||||
mod shuffling;
|
||||
mod ssz_generic;
|
||||
@ -22,6 +23,7 @@ pub use bls_priv_to_pub::*;
|
||||
pub use bls_sign_msg::*;
|
||||
pub use operations_deposit::*;
|
||||
pub use operations_exit::*;
|
||||
pub use operations_proposer_slashing::*;
|
||||
pub use operations_transfer::*;
|
||||
pub use shuffling::*;
|
||||
pub use ssz_generic::*;
|
||||
|
42
tests/ef_tests/src/cases/operations_proposer_slashing.rs
Normal file
42
tests/ef_tests/src/cases/operations_proposer_slashing.rs
Normal file
@ -0,0 +1,42 @@
|
||||
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<E: EthSpec> {
|
||||
pub description: String,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub pre: BeaconState<E>,
|
||||
pub proposer_slashing: ProposerSlashing,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub post: Option<BeaconState<E>>,
|
||||
}
|
||||
|
||||
impl<E: EthSpec> YamlDecode for OperationsProposerSlashing<E> {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> Case for OperationsProposerSlashing<E> {
|
||||
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::spec()).unwrap();
|
||||
|
||||
let result = process_proposer_slashings(&mut state, &[proposer_slashing], &E::spec());
|
||||
|
||||
let mut result = result.and_then(|_| Ok(state));
|
||||
|
||||
compare_beacon_state_results_without_caches(&mut result, &mut expected)
|
||||
}
|
||||
}
|
@ -71,6 +71,12 @@ impl Doc {
|
||||
("operations", "voluntary_exit", "minimal") => {
|
||||
run_test::<OperationsExit<MinimalEthSpec>>(self)
|
||||
}
|
||||
("operations", "proposer_slashing", "mainnet") => {
|
||||
run_test::<OperationsProposerSlashing<MainnetEthSpec>>(self)
|
||||
}
|
||||
("operations", "proposer_slashing", "minimal") => {
|
||||
run_test::<OperationsProposerSlashing<MinimalEthSpec>>(self)
|
||||
}
|
||||
(runner, handler, config) => panic!(
|
||||
"No implementation for runner: \"{}\", handler: \"{}\", config: \"{}\"",
|
||||
runner, handler, config
|
||||
|
@ -100,6 +100,16 @@ fn operations_exit() {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "fake_crypto"))]
|
||||
fn operations_proposer_slashing() {
|
||||
yaml_files_in_test_dir(&Path::new("operations").join("proposer_slashing"))
|
||||
.into_par_iter()
|
||||
.for_each(|file| {
|
||||
Doc::assert_tests_pass(file);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "fake_crypto"))]
|
||||
fn bls() {
|
||||
|
Loading…
Reference in New Issue
Block a user