mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-22 14:24:44 +00:00
Add transfer ef tests
This commit is contained in:
@@ -8,6 +8,7 @@ mod bls_g2_uncompressed;
|
||||
mod bls_priv_to_pub;
|
||||
mod bls_sign_msg;
|
||||
mod operations_deposit;
|
||||
mod operations_transfer;
|
||||
mod ssz_generic;
|
||||
mod ssz_static;
|
||||
|
||||
@@ -18,6 +19,7 @@ pub use bls_g2_uncompressed::*;
|
||||
pub use bls_priv_to_pub::*;
|
||||
pub use bls_sign_msg::*;
|
||||
pub use operations_deposit::*;
|
||||
pub use operations_transfer::*;
|
||||
pub use ssz_generic::*;
|
||||
pub use ssz_static::*;
|
||||
|
||||
|
||||
35
tests/ef_tests/src/cases/operations_transfer.rs
Normal file
35
tests/ef_tests/src/cases/operations_transfer.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
use super::*;
|
||||
use crate::case_result::compare_beacon_state_results_without_caches;
|
||||
use serde_derive::Deserialize;
|
||||
use state_processing::per_block_processing::process_transfers;
|
||||
use types::{BeaconState, EthSpec, Transfer};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct OperationsTransfer<E: EthSpec> {
|
||||
pub description: String,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub pre: BeaconState<E>,
|
||||
pub transfer: Transfer,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub post: Option<BeaconState<E>>,
|
||||
}
|
||||
|
||||
impl<E: EthSpec> YamlDecode for OperationsTransfer<E> {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: EthSpec> Case for OperationsTransfer<E> {
|
||||
fn result(&self, _case_index: usize) -> Result<(), Error> {
|
||||
let mut state = self.pre.clone();
|
||||
let transfer = self.transfer.clone();
|
||||
let mut expected = self.post.clone();
|
||||
|
||||
let result = process_transfers(&mut state, &[transfer], &E::spec());
|
||||
|
||||
let mut result = result.and_then(|_| Ok(state));
|
||||
|
||||
compare_beacon_state_results_without_caches(&mut result, &mut expected)
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,12 @@ impl Doc {
|
||||
("operations", "deposit", "minimal") => {
|
||||
run_test::<OperationsDeposit<MinimalEthSpec>>(self)
|
||||
}
|
||||
("operations", "transfer", "mainnet") => {
|
||||
run_test::<OperationsTransfer<MainnetEthSpec>>(self)
|
||||
}
|
||||
("operations", "transfer", "minimal") => {
|
||||
run_test::<OperationsTransfer<MinimalEthSpec>>(self)
|
||||
}
|
||||
(runner, handler, config) => panic!(
|
||||
"No implementation for runner: \"{}\", handler: \"{}\", config: \"{}\"",
|
||||
runner, handler, config
|
||||
|
||||
Reference in New Issue
Block a user