Merge branch 'docker-env' into v0.6.1

This commit is contained in:
Paul Hauner
2019-06-13 10:37:35 -04:00
142 changed files with 3186 additions and 2062 deletions

View File

@@ -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())
}
}

View File

@@ -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())
}
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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())
}
}

View File

@@ -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
}

View File

@@ -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)
}

View File

@@ -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();

View File

@@ -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));

View File

@@ -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));

View File

@@ -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)
}

View File

@@ -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));

View File

@@ -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));

View File

@@ -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));

View File

@@ -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);

View File

@@ -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

View File

@@ -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))

View File

@@ -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()
})

View File

@@ -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>,
{

View File

@@ -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)))
}
}