mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2024-12-29 07:17:17 +00:00
Rename test_harness::manifest to test_case
I thing `TestCase` is better than manifest -- a manifest is more of a list of items than a series of steps and checks. Plus it conflicts with a Cargo manifest.
This commit is contained in:
parent
48fc709109
commit
a29eca57a1
@ -1,11 +1,11 @@
|
|||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
use env_logger::{Builder, Env};
|
use env_logger::{Builder, Env};
|
||||||
use manifest::Manifest;
|
|
||||||
use std::{fs::File, io::prelude::*};
|
use std::{fs::File, io::prelude::*};
|
||||||
|
use test_case::TestCase;
|
||||||
use yaml_rust::YamlLoader;
|
use yaml_rust::YamlLoader;
|
||||||
|
|
||||||
mod beacon_chain_harness;
|
mod beacon_chain_harness;
|
||||||
mod manifest;
|
mod test_case;
|
||||||
mod validator_harness;
|
mod validator_harness;
|
||||||
|
|
||||||
use validator_harness::ValidatorHarness;
|
use validator_harness::ValidatorHarness;
|
||||||
@ -14,12 +14,12 @@ fn main() {
|
|||||||
let matches = App::new("Lighthouse Test Harness Runner")
|
let matches = App::new("Lighthouse Test Harness Runner")
|
||||||
.version("0.0.1")
|
.version("0.0.1")
|
||||||
.author("Sigma Prime <contact@sigmaprime.io>")
|
.author("Sigma Prime <contact@sigmaprime.io>")
|
||||||
.about("Runs `test_harness` using a YAML manifest.")
|
.about("Runs `test_harness` using a YAML test_case.")
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("yaml")
|
Arg::with_name("yaml")
|
||||||
.long("yaml")
|
.long("yaml")
|
||||||
.value_name("FILE")
|
.value_name("FILE")
|
||||||
.help("YAML file manifest.")
|
.help("YAML file test_case.")
|
||||||
.required(true),
|
.required(true),
|
||||||
)
|
)
|
||||||
.get_matches();
|
.get_matches();
|
||||||
@ -37,21 +37,21 @@ fn main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for doc in &docs {
|
for doc in &docs {
|
||||||
// For each `test_cases` YAML in the document, build a `Manifest`, execute it and
|
// For each `test_cases` YAML in the document, build a `TestCase`, execute it and
|
||||||
// assert that the execution result matches the manifest description.
|
// assert that the execution result matches the test_case description.
|
||||||
//
|
//
|
||||||
// In effect, for each `test_case` a new `BeaconChainHarness` is created from genesis
|
// In effect, for each `test_case` a new `BeaconChainHarness` is created from genesis
|
||||||
// and a new `BeaconChain` is built as per the manifest.
|
// and a new `BeaconChain` is built as per the test_case.
|
||||||
//
|
//
|
||||||
// After the `BeaconChain` has been built out as per the manifest, a dump of all blocks
|
// After the `BeaconChain` has been built out as per the test_case, a dump of all blocks
|
||||||
// and states in the chain is obtained and checked against the `results` specified in
|
// and states in the chain is obtained and checked against the `results` specified in
|
||||||
// the `test_case`.
|
// the `test_case`.
|
||||||
//
|
//
|
||||||
// If any of the expectations in the results are not met, the process
|
// If any of the expectations in the results are not met, the process
|
||||||
// panics with a message.
|
// panics with a message.
|
||||||
for test_case in doc["test_cases"].as_vec().unwrap() {
|
for test_case in doc["test_cases"].as_vec().unwrap() {
|
||||||
let manifest = Manifest::from_yaml(test_case);
|
let test_case = TestCase::from_yaml(test_case);
|
||||||
manifest.assert_result_valid(manifest.execute())
|
test_case.assert_result_valid(test_case.execute())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
mod beacon_chain_harness;
|
mod beacon_chain_harness;
|
||||||
pub mod manifest;
|
pub mod test_case;
|
||||||
mod validator_harness;
|
mod validator_harness;
|
||||||
|
|
||||||
pub use self::beacon_chain_harness::BeaconChainHarness;
|
pub use self::beacon_chain_harness::BeaconChainHarness;
|
||||||
|
@ -23,18 +23,18 @@ pub use state_check::StateCheck;
|
|||||||
///
|
///
|
||||||
/// Typical workflow is:
|
/// Typical workflow is:
|
||||||
///
|
///
|
||||||
/// 1. Instantiate the `Manifest` from YAML: `let manifest = Manifest::from_yaml(&my_yaml);`
|
/// 1. Instantiate the `TestCase` from YAML: `let test_case = TestCase::from_yaml(&my_yaml);`
|
||||||
/// 2. Execute the manifest: `let result = manifest.execute();`
|
/// 2. Execute the test_case: `let result = test_case.execute();`
|
||||||
/// 3. Test the results against the manifest: `manifest.assert_result_valid(result);`
|
/// 3. Test the results against the test_case: `test_case.assert_result_valid(result);`
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Manifest {
|
pub struct TestCase {
|
||||||
/// Defines the execution.
|
/// Defines the execution.
|
||||||
pub config: Config,
|
pub config: Config,
|
||||||
/// Defines tests to run against the execution result.
|
/// Defines tests to run against the execution result.
|
||||||
pub results: Results,
|
pub results: Results,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The result of executing a `Manifest`.
|
/// The result of executing a `TestCase`.
|
||||||
///
|
///
|
||||||
pub struct ExecutionResult {
|
pub struct ExecutionResult {
|
||||||
/// The canonical beacon chain generated from the execution.
|
/// The canonical beacon chain generated from the execution.
|
||||||
@ -43,8 +43,8 @@ pub struct ExecutionResult {
|
|||||||
pub spec: ChainSpec,
|
pub spec: ChainSpec,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Manifest {
|
impl TestCase {
|
||||||
/// Load the manifest from a YAML document.
|
/// Load the test case from a YAML document.
|
||||||
pub fn from_yaml(test_case: &Yaml) -> Self {
|
pub fn from_yaml(test_case: &Yaml) -> Self {
|
||||||
Self {
|
Self {
|
||||||
results: Results::from_yaml(&test_case["results"]),
|
results: Results::from_yaml(&test_case["results"]),
|
||||||
@ -65,7 +65,7 @@ impl Manifest {
|
|||||||
spec
|
spec
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Executes the manifest, returning an `ExecutionResult`.
|
/// Executes the test case, returning an `ExecutionResult`.
|
||||||
pub fn execute(&self) -> ExecutionResult {
|
pub fn execute(&self) -> ExecutionResult {
|
||||||
let spec = self.spec();
|
let spec = self.spec();
|
||||||
let validator_count = self.config.deposits_for_chain_start;
|
let validator_count = self.config.deposits_for_chain_start;
|
@ -3,7 +3,7 @@ use super::yaml_helpers::as_usize;
|
|||||||
use yaml_rust::Yaml;
|
use yaml_rust::Yaml;
|
||||||
|
|
||||||
/// A series of tests to be carried out upon an `ExecutionResult`, returned from executing a
|
/// A series of tests to be carried out upon an `ExecutionResult`, returned from executing a
|
||||||
/// `Manifest`.
|
/// `TestCase`.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Results {
|
pub struct Results {
|
||||||
pub num_skipped_slots: Option<usize>,
|
pub num_skipped_slots: Option<usize>,
|
@ -4,7 +4,7 @@ use types::*;
|
|||||||
use yaml_rust::Yaml;
|
use yaml_rust::Yaml;
|
||||||
|
|
||||||
/// Tests to be conducted upon a `BeaconState` object generated during the execution of a
|
/// Tests to be conducted upon a `BeaconState` object generated during the execution of a
|
||||||
/// `Manifest`.
|
/// `TestCase`.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct StateCheck {
|
pub struct StateCheck {
|
||||||
/// Checked against `beacon_state.slot`.
|
/// Checked against `beacon_state.slot`.
|
Loading…
Reference in New Issue
Block a user