This commit is contained in:
Deirdre Connolly 2020-02-01 02:16:21 -05:00 committed by Deirdre Connolly
parent 54628d889e
commit d12db25acb
2 changed files with 14 additions and 16 deletions

View File

@ -3,8 +3,6 @@ use std::io::{Cursor, Write};
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use proptest::{ use proptest::{
arbitrary::{any, Arbitrary}, arbitrary::{any, Arbitrary},
collection::vec,
option,
prelude::*, prelude::*,
}; };

View File

@ -20,12 +20,6 @@ const EQUIHASH_SOLUTION_SIZE: usize = 1344;
/// length of this type is fixed. /// length of this type is fixed.
pub struct EquihashSolution(pub [u8; EQUIHASH_SOLUTION_SIZE]); pub struct EquihashSolution(pub [u8; EQUIHASH_SOLUTION_SIZE]);
impl Default for EquihashSolution {
fn default() -> Self {
EquihashSolution([0; EQUIHASH_SOLUTION_SIZE])
}
}
impl PartialEq<EquihashSolution> for EquihashSolution { impl PartialEq<EquihashSolution> for EquihashSolution {
fn eq(&self, other: &EquihashSolution) -> bool { fn eq(&self, other: &EquihashSolution) -> bool {
self.0.as_ref() == other.0.as_ref() self.0.as_ref() == other.0.as_ref()
@ -87,18 +81,24 @@ impl Arbitrary for EquihashSolution {
} }
#[cfg(test)] #[cfg(test)]
proptest! { mod tests {
#[test] use super::*;
fn encrypted_ciphertext_roundtrip(solution in any::<EquihashSolution>()) {
let mut data = Vec::new(); proptest! {
solution.zcash_serialize(&mut data).expect("EquihashSolution should serialize"); #[test]
fn equihash_solution_roundtrip(solution in any::<EquihashSolution>()) {
let solution2 = EquihashSolution::zcash_deserialize(&data[..]).expect("randomized EquihashSolution should deserialize"); let mut data = Vec::new();
solution.zcash_serialize(&mut data).expect("EquihashSolution should serialize");
let solution2 = EquihashSolution::zcash_deserialize(&data[..])
.expect("randomized EquihashSolution should deserialize");
prop_assert_eq![solution, solution2];
}
prop_assert_eq![solution, solution2];
} }
} }