From 82bcbddb57f12040299ea621909830b5ad22827c Mon Sep 17 00:00:00 2001 From: Sean Bowe Date: Fri, 23 Sep 2016 23:02:38 -0600 Subject: [PATCH] Add tests for to_string/from_string behavior. --- src/protocol/digest.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/protocol/digest.rs b/src/protocol/digest.rs index 90213b8..2541f7c 100644 --- a/src/protocol/digest.rs +++ b/src/protocol/digest.rs @@ -99,3 +99,21 @@ impl Digest256 { } } } + +#[test] +fn digest_string_repr() { + use super::secrets::*; + + let rng = &mut ::rand::thread_rng(); + + let privkey = PrivateKey::new(rng); + + for _ in 0..100 { + let pubkey = privkey.pubkey(rng); + let comm = pubkey.hash(); + let string = comm.to_string(); + let newcomm = Digest256::from_string(&string).unwrap(); + + assert!(comm == newcomm); + } +}