mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 05:48:31 +00:00
Merge branch 'docker-env' into v0.6.1
This commit is contained in:
@@ -28,13 +28,10 @@ pub fn compare_beacon_state_results_without_caches<T: EthSpec, E: Debug>(
|
||||
result: &mut Result<BeaconState<T>, E>,
|
||||
expected: &mut Option<BeaconState<T>>,
|
||||
) -> Result<(), Error> {
|
||||
match (result.as_mut(), expected.as_mut()) {
|
||||
(Ok(ref mut result), Some(ref mut expected)) => {
|
||||
result.drop_all_caches();
|
||||
expected.drop_all_caches();
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
if let (Ok(ref mut result), Some(ref mut expected)) = (result.as_mut(), expected.as_mut()) {
|
||||
result.drop_all_caches();
|
||||
expected.drop_all_caches();
|
||||
}
|
||||
|
||||
compare_result_detailed(&result, &expected)
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ where
|
||||
|
||||
impl<T: YamlDecode> YamlDecode for Cases<T> {
|
||||
/// Decodes a YAML list of test cases
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
let mut p = 0;
|
||||
let mut elems: Vec<&str> = yaml
|
||||
.match_indices("\n- ")
|
||||
|
||||
@@ -10,8 +10,8 @@ pub struct BlsAggregatePubkeys {
|
||||
}
|
||||
|
||||
impl YamlDecode for BlsAggregatePubkeys {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ pub struct BlsAggregateSigs {
|
||||
}
|
||||
|
||||
impl YamlDecode for BlsAggregateSigs {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ pub struct BlsG2Compressed {
|
||||
}
|
||||
|
||||
impl YamlDecode for BlsG2Compressed {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,13 +52,13 @@ impl Case for BlsG2Compressed {
|
||||
}
|
||||
|
||||
// Converts a vector to u64 (from big endian)
|
||||
fn bytes_to_u64(array: &Vec<u8>) -> u64 {
|
||||
fn bytes_to_u64(array: &[u8]) -> u64 {
|
||||
let mut result: u64 = 0;
|
||||
for (i, value) in array.iter().rev().enumerate() {
|
||||
if i == 8 {
|
||||
break;
|
||||
}
|
||||
result += u64::pow(2, i as u32 * 8) * (*value as u64);
|
||||
result += u64::pow(2, i as u32 * 8) * u64::from(*value);
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ pub struct BlsG2Uncompressed {
|
||||
}
|
||||
|
||||
impl YamlDecode for BlsG2Uncompressed {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,13 +56,13 @@ impl Case for BlsG2Uncompressed {
|
||||
}
|
||||
|
||||
// Converts a vector to u64 (from big endian)
|
||||
fn bytes_to_u64(array: &Vec<u8>) -> u64 {
|
||||
fn bytes_to_u64(array: &[u8]) -> u64 {
|
||||
let mut result: u64 = 0;
|
||||
for (i, value) in array.iter().rev().enumerate() {
|
||||
if i == 8 {
|
||||
break;
|
||||
}
|
||||
result += u64::pow(2, i as u32 * 8) * (*value as u64);
|
||||
result += u64::pow(2, i as u32 * 8) * u64::from(*value);
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ pub struct BlsPrivToPub {
|
||||
}
|
||||
|
||||
impl YamlDecode for BlsPrivToPub {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ pub struct BlsSign {
|
||||
}
|
||||
|
||||
impl YamlDecode for BlsSign {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,13 +46,13 @@ impl Case for BlsSign {
|
||||
}
|
||||
|
||||
// Converts a vector to u64 (from big endian)
|
||||
fn bytes_to_u64(array: &Vec<u8>) -> u64 {
|
||||
fn bytes_to_u64(array: &[u8]) -> u64 {
|
||||
let mut result: u64 = 0;
|
||||
for (i, value) in array.iter().rev().enumerate() {
|
||||
if i == 8 {
|
||||
break;
|
||||
}
|
||||
result += u64::pow(2, i as u32 * 8) * (*value as u64);
|
||||
result += u64::pow(2, i as u32 * 8) * u64::from(*value);
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ pub struct EpochProcessingCrosslinks<E: EthSpec> {
|
||||
}
|
||||
|
||||
impl<E: EthSpec> YamlDecode for EpochProcessingCrosslinks<E> {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@ impl<E: EthSpec> Case for EpochProcessingCrosslinks<E> {
|
||||
let mut expected = self.post.clone();
|
||||
|
||||
// Processing requires the epoch cache.
|
||||
state.build_all_caches(&E::spec()).unwrap();
|
||||
state.build_all_caches(&E::default_spec()).unwrap();
|
||||
|
||||
let mut result = process_crosslinks(&mut state, &E::spec()).map(|_| state);
|
||||
let mut result = process_crosslinks(&mut state, &E::default_spec()).map(|_| state);
|
||||
|
||||
compare_beacon_state_results_without_caches(&mut result, &mut expected)
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ pub struct EpochProcessingRegistryUpdates<E: EthSpec> {
|
||||
}
|
||||
|
||||
impl<E: EthSpec> YamlDecode for EpochProcessingRegistryUpdates<E> {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ impl<E: EthSpec> Case for EpochProcessingRegistryUpdates<E> {
|
||||
fn result(&self, _case_index: usize) -> Result<(), Error> {
|
||||
let mut state = self.pre.clone();
|
||||
let mut expected = self.post.clone();
|
||||
let spec = &E::spec();
|
||||
let spec = &E::default_spec();
|
||||
|
||||
// Processing requires the epoch cache.
|
||||
state.build_all_caches(spec).unwrap();
|
||||
|
||||
@@ -17,8 +17,8 @@ pub struct OperationsAttestation<E: EthSpec> {
|
||||
}
|
||||
|
||||
impl<E: EthSpec> YamlDecode for OperationsAttestation<E> {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ impl<E: EthSpec> Case for OperationsAttestation<E> {
|
||||
}
|
||||
|
||||
fn result(&self, _case_index: usize) -> Result<(), Error> {
|
||||
let spec = &E::default_spec();
|
||||
|
||||
self.bls_setting.unwrap_or_default().check()?;
|
||||
|
||||
let mut state = self.pre.clone();
|
||||
@@ -35,9 +37,9 @@ impl<E: EthSpec> Case for OperationsAttestation<E> {
|
||||
let mut expected = self.post.clone();
|
||||
|
||||
// Processing requires the epoch cache.
|
||||
state.build_all_caches(&E::spec()).unwrap();
|
||||
state.build_all_caches(spec).unwrap();
|
||||
|
||||
let result = process_attestations(&mut state, &[attestation], &E::spec());
|
||||
let result = process_attestations(&mut state, &[attestation], spec);
|
||||
|
||||
let mut result = result.and_then(|_| Ok(state));
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ pub struct OperationsAttesterSlashing<E: EthSpec> {
|
||||
}
|
||||
|
||||
impl<E: EthSpec> YamlDecode for OperationsAttesterSlashing<E> {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,9 +35,10 @@ impl<E: EthSpec> Case for OperationsAttesterSlashing<E> {
|
||||
let mut expected = self.post.clone();
|
||||
|
||||
// Processing requires the epoch cache.
|
||||
state.build_all_caches(&E::spec()).unwrap();
|
||||
state.build_all_caches(&E::default_spec()).unwrap();
|
||||
|
||||
let result = process_attester_slashings(&mut state, &[attester_slashing], &E::spec());
|
||||
let result =
|
||||
process_attester_slashings(&mut state, &[attester_slashing], &E::default_spec());
|
||||
|
||||
let mut result = result.and_then(|_| Ok(state));
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ pub struct OperationsBlockHeader<E: EthSpec> {
|
||||
}
|
||||
|
||||
impl<E: EthSpec> YamlDecode for OperationsBlockHeader<E> {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,16 +28,18 @@ impl<E: EthSpec> Case for OperationsBlockHeader<E> {
|
||||
}
|
||||
|
||||
fn result(&self, _case_index: usize) -> Result<(), Error> {
|
||||
let spec = &E::default_spec();
|
||||
|
||||
self.bls_setting.unwrap_or_default().check()?;
|
||||
|
||||
let mut state = self.pre.clone();
|
||||
let mut expected = self.post.clone();
|
||||
|
||||
// Processing requires the epoch cache.
|
||||
state.build_all_caches(&E::spec()).unwrap();
|
||||
state.build_all_caches(spec).unwrap();
|
||||
|
||||
let mut result =
|
||||
process_block_header(&mut state, &self.block, &E::spec(), true).map(|_| state);
|
||||
process_block_header(&mut state, &self.block, spec, true).map(|_| state);
|
||||
|
||||
compare_beacon_state_results_without_caches(&mut result, &mut expected)
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ pub struct OperationsDeposit<E: EthSpec> {
|
||||
}
|
||||
|
||||
impl<E: EthSpec> YamlDecode for OperationsDeposit<E> {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ impl<E: EthSpec> Case for OperationsDeposit<E> {
|
||||
let deposit = self.deposit.clone();
|
||||
let mut expected = self.post.clone();
|
||||
|
||||
let result = process_deposits(&mut state, &[deposit], &E::spec());
|
||||
let result = process_deposits(&mut state, &[deposit], &E::default_spec());
|
||||
|
||||
let mut result = result.and_then(|_| Ok(state));
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ pub struct OperationsExit<E: EthSpec> {
|
||||
}
|
||||
|
||||
impl<E: EthSpec> YamlDecode for OperationsExit<E> {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ impl<E: EthSpec> Case for OperationsExit<E> {
|
||||
let mut expected = self.post.clone();
|
||||
|
||||
// Exit processing requires the epoch cache.
|
||||
state.build_all_caches(&E::spec()).unwrap();
|
||||
state.build_all_caches(&E::default_spec()).unwrap();
|
||||
|
||||
let result = process_exits(&mut state, &[exit], &E::spec());
|
||||
let result = process_exits(&mut state, &[exit], &E::default_spec());
|
||||
|
||||
let mut result = result.and_then(|_| Ok(state));
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ pub struct OperationsProposerSlashing<E: EthSpec> {
|
||||
}
|
||||
|
||||
impl<E: EthSpec> YamlDecode for OperationsProposerSlashing<E> {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,9 +35,10 @@ impl<E: EthSpec> Case for OperationsProposerSlashing<E> {
|
||||
let mut expected = self.post.clone();
|
||||
|
||||
// Processing requires the epoch cache.
|
||||
state.build_all_caches(&E::spec()).unwrap();
|
||||
state.build_all_caches(&E::default_spec()).unwrap();
|
||||
|
||||
let result = process_proposer_slashings(&mut state, &[proposer_slashing], &E::spec());
|
||||
let result =
|
||||
process_proposer_slashings(&mut state, &[proposer_slashing], &E::default_spec());
|
||||
|
||||
let mut result = result.and_then(|_| Ok(state));
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ pub struct OperationsTransfer<E: EthSpec> {
|
||||
}
|
||||
|
||||
impl<E: EthSpec> YamlDecode for OperationsTransfer<E> {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ impl<E: EthSpec> Case for OperationsTransfer<E> {
|
||||
let mut expected = self.post.clone();
|
||||
|
||||
// Transfer processing requires the epoch cache.
|
||||
state.build_all_caches(&E::spec()).unwrap();
|
||||
state.build_all_caches(&E::default_spec()).unwrap();
|
||||
|
||||
let mut spec = E::spec();
|
||||
let mut spec = E::default_spec();
|
||||
spec.max_transfers = 1;
|
||||
|
||||
let result = process_transfers(&mut state, &[transfer], &spec);
|
||||
|
||||
@@ -17,8 +17,8 @@ pub struct SanityBlocks<E: EthSpec> {
|
||||
}
|
||||
|
||||
impl<E: EthSpec> YamlDecode for SanityBlocks<E> {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,10 +42,10 @@ impl<E: EthSpec> Case for SanityBlocks<E> {
|
||||
|
||||
let mut state = self.pre.clone();
|
||||
let mut expected = self.post.clone();
|
||||
let spec = &E::spec();
|
||||
let spec = &E::default_spec();
|
||||
|
||||
// Processing requires the epoch cache.
|
||||
state.build_all_caches(&E::spec()).unwrap();
|
||||
state.build_all_caches(spec).unwrap();
|
||||
|
||||
let mut result = self
|
||||
.blocks
|
||||
|
||||
@@ -15,8 +15,8 @@ pub struct SanitySlots<E: EthSpec> {
|
||||
}
|
||||
|
||||
impl<E: EthSpec> YamlDecode for SanitySlots<E> {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,10 +28,10 @@ impl<E: EthSpec> Case for SanitySlots<E> {
|
||||
fn result(&self, _case_index: usize) -> Result<(), Error> {
|
||||
let mut state = self.pre.clone();
|
||||
let mut expected = self.post.clone();
|
||||
let spec = &E::spec();
|
||||
let spec = &E::default_spec();
|
||||
|
||||
// Processing requires the epoch cache.
|
||||
state.build_all_caches(&E::spec()).unwrap();
|
||||
state.build_all_caches(spec).unwrap();
|
||||
|
||||
let mut result = (0..self.slots)
|
||||
.try_for_each(|_| per_slot_processing(&mut state, spec))
|
||||
|
||||
@@ -14,8 +14,8 @@ pub struct Shuffling<T> {
|
||||
}
|
||||
|
||||
impl<T> YamlDecode for Shuffling<T> {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,13 +24,12 @@ impl<T: EthSpec> Case for Shuffling<T> {
|
||||
if self.count == 0 {
|
||||
compare_result::<_, Error>(&Ok(vec![]), &Some(self.shuffled.clone()))?;
|
||||
} else {
|
||||
let spec = T::spec();
|
||||
let spec = T::default_spec();
|
||||
let seed = hex::decode(&self.seed[2..])
|
||||
.map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?;
|
||||
|
||||
// Test get_permuted_index
|
||||
let shuffling = (0..self.count)
|
||||
.into_iter()
|
||||
.map(|i| {
|
||||
get_permutated_index(i, self.count, &seed, spec.shuffle_round_count).unwrap()
|
||||
})
|
||||
|
||||
@@ -15,8 +15,8 @@ pub struct SszGeneric {
|
||||
}
|
||||
|
||||
impl YamlDecode for SszGeneric {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(&yaml.as_str()).unwrap())
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
Ok(serde_yaml::from_str(yaml).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,11 +45,7 @@ impl Case for SszGeneric {
|
||||
}
|
||||
|
||||
/// Execute a `ssz_generic` test case.
|
||||
fn ssz_generic_test<T>(
|
||||
should_be_ok: bool,
|
||||
ssz: &String,
|
||||
value: &Option<String>,
|
||||
) -> Result<(), Error>
|
||||
fn ssz_generic_test<T>(should_be_ok: bool, ssz: &str, value: &Option<String>) -> Result<(), Error>
|
||||
where
|
||||
T: Decode + YamlDecode + Debug + PartialEq<T>,
|
||||
{
|
||||
|
||||
@@ -55,7 +55,7 @@ where
|
||||
}
|
||||
|
||||
impl<E: EthSpec + serde::de::DeserializeOwned> YamlDecode for SszStatic<E> {
|
||||
fn yaml_decode(yaml: &String) -> Result<Self, Error> {
|
||||
fn yaml_decode(yaml: &str) -> Result<Self, Error> {
|
||||
serde_yaml::from_str(yaml).map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@ use crate::case_result::CaseResult;
|
||||
use crate::cases::*;
|
||||
use crate::doc_header::DocHeader;
|
||||
use crate::error::Error;
|
||||
use crate::eth_specs::{MainnetEthSpec, MinimalEthSpec};
|
||||
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};
|
||||
use types::{MainnetEthSpec, MinimalEthSpec};
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct Doc {
|
||||
@@ -190,7 +190,7 @@ pub fn print_results(
|
||||
);
|
||||
println!("Title: {}", header.title);
|
||||
println!("File: {:?}", doc.path);
|
||||
println!("");
|
||||
println!();
|
||||
println!(
|
||||
"{} tests, {} failed, {} skipped (known failure), {} skipped (bls), {} passed.",
|
||||
results.len(),
|
||||
@@ -199,7 +199,7 @@ pub fn print_results(
|
||||
skipped_bls.len(),
|
||||
results.len() - skipped_bls.len() - skipped_known_failures.len() - failed.len()
|
||||
);
|
||||
println!("");
|
||||
println!();
|
||||
|
||||
for case in skipped_known_failures {
|
||||
println!("-------");
|
||||
@@ -220,5 +220,5 @@ pub fn print_results(
|
||||
);
|
||||
println!("{}", error.message());
|
||||
}
|
||||
println!("");
|
||||
println!();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ mod cases;
|
||||
mod doc;
|
||||
mod doc_header;
|
||||
mod error;
|
||||
mod eth_specs;
|
||||
mod yaml_decode;
|
||||
|
||||
/// Defined where an object can return the results of some test(s) adhering to the Ethereum
|
||||
|
||||
@@ -8,14 +8,14 @@ pub use utils::*;
|
||||
|
||||
pub trait YamlDecode: Sized {
|
||||
/// Decode an object from the test specification YAML.
|
||||
fn yaml_decode(string: &String) -> Result<Self, Error>;
|
||||
fn yaml_decode(string: &str) -> Result<Self, Error>;
|
||||
}
|
||||
|
||||
/// Basic types can general be decoded with the `parse` fn if they implement `str::FromStr`.
|
||||
macro_rules! impl_via_parse {
|
||||
($ty: ty) => {
|
||||
impl YamlDecode for $ty {
|
||||
fn yaml_decode(string: &String) -> Result<Self, Error> {
|
||||
fn yaml_decode(string: &str) -> Result<Self, Error> {
|
||||
string
|
||||
.parse::<Self>()
|
||||
.map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))
|
||||
@@ -34,7 +34,7 @@ impl_via_parse!(u64);
|
||||
macro_rules! impl_via_from_dec_str {
|
||||
($ty: ty) => {
|
||||
impl YamlDecode for $ty {
|
||||
fn yaml_decode(string: &String) -> Result<Self, Error> {
|
||||
fn yaml_decode(string: &str) -> Result<Self, Error> {
|
||||
Self::from_dec_str(string).map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ impl_via_from_dec_str!(U256);
|
||||
macro_rules! impl_via_serde_yaml {
|
||||
($ty: ty) => {
|
||||
impl YamlDecode for $ty {
|
||||
fn yaml_decode(string: &String) -> Result<Self, Error> {
|
||||
fn yaml_decode(string: &str) -> Result<Self, Error> {
|
||||
serde_yaml::from_str(string)
|
||||
.map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ pub fn yaml_split_header_and_cases(mut yaml: String) -> (String, String) {
|
||||
// + 1 to skip the \n we used for matching.
|
||||
let mut test_cases = yaml.split_off(test_cases_start + 1);
|
||||
|
||||
let end_of_first_line = test_cases.find("\n").unwrap();
|
||||
let end_of_first_line = test_cases.find('\n').unwrap();
|
||||
let test_cases = test_cases.split_off(end_of_first_line + 1);
|
||||
|
||||
(yaml, test_cases)
|
||||
|
||||
Reference in New Issue
Block a user