Add parsing (not executing) of deposit tests
This commit is contained in:
parent
07b94b30ba
commit
95b0df7087
@ -18,6 +18,7 @@ serde_yaml = "0.8"
|
||||
ssz = { path = "../../eth2/utils/ssz" }
|
||||
tree_hash = { path = "../../eth2/utils/tree_hash" }
|
||||
cached_tree_hash = { path = "../../eth2/utils/cached_tree_hash" }
|
||||
state_processing = { path = "../../eth2/state_processing" }
|
||||
types = { path = "../../eth2/types" }
|
||||
walkdir = "2"
|
||||
yaml-rust = { git = "https://github.com/sigp/yaml-rust", branch = "escape_all_str"}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 161a36ee6232d8d251d798c8262638ed0c34c9c6
|
||||
Subproject commit 6fde1e806b340d946839d6261c63c779f0cadd81
|
@ -1,6 +1,4 @@
|
||||
use super::*;
|
||||
use crate::yaml_decode::*;
|
||||
use yaml_rust::YamlLoader;
|
||||
|
||||
mod bls_aggregate_pubkeys;
|
||||
mod bls_aggregate_sigs;
|
||||
@ -8,6 +6,7 @@ mod bls_g2_compressed;
|
||||
mod bls_g2_uncompressed;
|
||||
mod bls_priv_to_pub;
|
||||
mod bls_sign_msg;
|
||||
mod operations_deposit;
|
||||
mod ssz_generic;
|
||||
mod ssz_static;
|
||||
|
||||
@ -17,6 +16,7 @@ pub use bls_g2_compressed::*;
|
||||
pub use bls_g2_uncompressed::*;
|
||||
pub use bls_priv_to_pub::*;
|
||||
pub use bls_sign_msg::*;
|
||||
pub use operations_deposit::*;
|
||||
pub use ssz_generic::*;
|
||||
pub use ssz_static::*;
|
||||
|
||||
|
34
tests/ef_tests/src/cases/operations_deposit.rs
Normal file
34
tests/ef_tests/src/cases/operations_deposit.rs
Normal file
@ -0,0 +1,34 @@
|
||||
use super::*;
|
||||
use serde_derive::Deserialize;
|
||||
use types::{BeaconState, Deposit, EthSpec};
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct OperationsDeposit<E: EthSpec> {
|
||||
pub description: String,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub pre: BeaconState<E>,
|
||||
pub deposit: Deposit,
|
||||
#[serde(bound = "E: EthSpec")]
|
||||
pub post: Option<BeaconState<E>>,
|
||||
}
|
||||
|
||||
impl<E: EthSpec> YamlDecode for OperationsDeposit<E> {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EthSpec> EfTest for Cases<OperationsDeposit<T>> {
|
||||
fn test_results<E: EthSpec>(&self) -> Vec<CaseResult> {
|
||||
self.test_cases
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, tc)| {
|
||||
// TODO: run test
|
||||
let result = Ok(());
|
||||
|
||||
CaseResult::new(i, tc, result)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ use crate::case_result::CaseResult;
|
||||
use crate::cases::*;
|
||||
use crate::doc_header::DocHeader;
|
||||
use crate::eth_specs::{MainnetEthSpec, MinimalEthSpec};
|
||||
use crate::yaml_decode::{extract_yaml_by_key, yaml_split_header_and_cases, YamlDecode};
|
||||
use crate::yaml_decode::{yaml_split_header_and_cases, YamlDecode};
|
||||
use crate::EfTest;
|
||||
use serde_derive::Deserialize;
|
||||
use std::{fs::File, io::prelude::*, path::PathBuf};
|
||||
@ -58,6 +58,12 @@ impl Doc {
|
||||
("bls", "msg_hash_uncompressed", "mainnet") => vec![],
|
||||
("bls", "priv_to_pub", "mainnet") => run_test::<BlsPrivToPub, MainnetEthSpec>(self),
|
||||
("bls", "sign_msg", "mainnet") => run_test::<BlsSign, MainnetEthSpec>(self),
|
||||
("operations", "deposit", "mainnet") => {
|
||||
run_test::<OperationsDeposit<MainnetEthSpec>, MainnetEthSpec>(self)
|
||||
}
|
||||
("operations", "deposit", "minimal") => {
|
||||
run_test::<OperationsDeposit<MinimalEthSpec>, MinimalEthSpec>(self)
|
||||
}
|
||||
(runner, handler, config) => panic!(
|
||||
"No implementation for runner: \"{}\", handler: \"{}\", config: \"{}\"",
|
||||
runner, handler, config
|
||||
|
@ -1,13 +1,13 @@
|
||||
use ef_tests::*;
|
||||
use rayon::prelude::*;
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
use walkdir::WalkDir;
|
||||
|
||||
fn yaml_files_in_test_dir(dir: &str) -> Vec<PathBuf> {
|
||||
let mut base_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||
base_path.push("eth2.0-spec-tests");
|
||||
base_path.push("tests");
|
||||
base_path.push(dir);
|
||||
fn yaml_files_in_test_dir(dir: &Path) -> Vec<PathBuf> {
|
||||
let base_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("eth2.0-spec-tests")
|
||||
.join("tests")
|
||||
.join(dir);
|
||||
|
||||
assert!(
|
||||
base_path.exists(),
|
||||
@ -34,7 +34,7 @@ fn yaml_files_in_test_dir(dir: &str) -> Vec<PathBuf> {
|
||||
#[test]
|
||||
#[cfg(feature = "fake_crypto")]
|
||||
fn ssz_generic() {
|
||||
yaml_files_in_test_dir("ssz_generic")
|
||||
yaml_files_in_test_dir(&Path::new("ssz_generic"))
|
||||
.into_par_iter()
|
||||
.for_each(|file| {
|
||||
Doc::assert_tests_pass(file);
|
||||
@ -44,17 +44,28 @@ fn ssz_generic() {
|
||||
#[test]
|
||||
#[cfg(feature = "fake_crypto")]
|
||||
fn ssz_static() {
|
||||
yaml_files_in_test_dir("ssz_static")
|
||||
yaml_files_in_test_dir(&Path::new("ssz_static"))
|
||||
.into_par_iter()
|
||||
.for_each(|file| {
|
||||
Doc::assert_tests_pass(file);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "fake_crypto")]
|
||||
fn operations_deposit() {
|
||||
yaml_files_in_test_dir(&Path::new("operations").join("deposit"))
|
||||
// .into_par_iter()
|
||||
.into_iter()
|
||||
.for_each(|file| {
|
||||
Doc::assert_tests_pass(file);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "fake_crypto"))]
|
||||
fn bls() {
|
||||
yaml_files_in_test_dir("bls")
|
||||
yaml_files_in_test_dir(&Path::new("bls"))
|
||||
.into_par_iter()
|
||||
.for_each(|file| {
|
||||
Doc::assert_tests_pass(file);
|
||||
|
Loading…
Reference in New Issue
Block a user