Skip to content
This repository has been archived by the owner on Mar 23, 2021. It is now read-only.

Commit

Permalink
Ensure seeds cannot be printed
Browse files Browse the repository at this point in the history
We don't want to display (or debug out) seeds.   Implement dummy methods for
Display trait and Debug.  Add test to ensure the dummy implementations don't get
changed.

Fixes: #722

Signed-off-by: tcharding <me@tobin.cc>
  • Loading branch information
tcharding authored and mergify-bot committed Jun 8, 2019
1 parent 021a204 commit 416f5c6
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion application/comit_node/src/seed.rs
Expand Up @@ -10,7 +10,13 @@ pub struct Seed(#[serde(with = "hex_serde")] [u8; SEED_LENGTH]);

impl fmt::Debug for Seed {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Seed")
write!(f, "do not implement")
}
}

impl fmt::Display for Seed {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "do not implement")
}
}

Expand Down Expand Up @@ -68,4 +74,14 @@ mod tests {

assert_ne!(random1, random2);
}

#[test]
fn test_display_and_debug_not_implemented() {
let seed = Seed::new_random().unwrap();

let out = format!("{}", seed);
assert_eq!(out, "do not implement".to_string());
let debug = format!("{:?}", seed);
assert_eq!(debug, "do not implement".to_string());
}
}

0 comments on commit 416f5c6

Please sign in to comment.