Add (de)serialization roundtrip proptext for shielded_data::(Encrypted,Out)Ciphertext

This commit is contained in:
Deirdre Connolly 2020-01-27 23:48:41 -05:00 committed by Deirdre Connolly
parent 2df20b9e6c
commit 283d06bb08
1 changed files with 28 additions and 0 deletions

View File

@ -327,3 +327,31 @@ impl Arbitrary for OutCiphertext {
type Strategy = BoxedStrategy<Self>;
}
#[cfg(test)]
proptest! {
#[test]
fn encrypted_ciphertext_roundtrip(ec in any::<EncryptedCiphertext>()) {
let mut data = Vec::new();
ec.zcash_serialize(&mut data).expect("EncryptedCiphertext should serialize");
let ec2 = EncryptedCiphertext::zcash_deserialize(&data[..]).expect("randomized EncryptedCiphertext should deserialize");
prop_assert_eq![ec, ec2];
}
#[test]
fn out_ciphertext_roundtrip(oc in any::<OutCiphertext>()) {
let mut data = Vec::new();
oc.zcash_serialize(&mut data).expect("OutCiphertext should serialize");
let oc2 = OutCiphertext::zcash_deserialize(&data[..]).expect("randomized OutCiphertext should deserialize");
prop_assert_eq![oc, oc2];
}
}