Cleanup
This commit is contained in:
parent
54628d889e
commit
d12db25acb
|
@ -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::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
proptest! {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn encrypted_ciphertext_roundtrip(solution in any::<EquihashSolution>()) {
|
fn equihash_solution_roundtrip(solution in any::<EquihashSolution>()) {
|
||||||
|
|
||||||
let mut data = Vec::new();
|
let mut data = Vec::new();
|
||||||
|
|
||||||
solution.zcash_serialize(&mut data).expect("EquihashSolution should serialize");
|
solution.zcash_serialize(&mut data).expect("EquihashSolution should serialize");
|
||||||
|
|
||||||
let solution2 = EquihashSolution::zcash_deserialize(&data[..]).expect("randomized EquihashSolution should deserialize");
|
let solution2 = EquihashSolution::zcash_deserialize(&data[..])
|
||||||
|
.expect("randomized EquihashSolution should deserialize");
|
||||||
|
|
||||||
prop_assert_eq![solution, solution2];
|
prop_assert_eq![solution, solution2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue