RelayId: Display the ID type on redacted identities.

Formerly we would display just the first characters of the identity,
without telling you what kind of ID it was.
This commit is contained in:
Nick Mathewson 2023-06-09 16:00:12 -04:00
parent a6ce079d4a
commit a542a3e93f
2 changed files with 3 additions and 4 deletions

View File

@ -208,10 +208,9 @@ impl Redactable for RelayId {
impl<'a> Redactable for RelayIdRef<'a> {
fn display_redacted(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
use std::fmt::Display as _;
match self {
RelayIdRef::Ed25519(k) => k.redacted().fmt(f),
RelayIdRef::Rsa(k) => k.redacted().fmt(f),
RelayIdRef::Ed25519(k) => write!(f, "ed25519:{}", k.redacted()),
RelayIdRef::Rsa(k) => write!(f, "${}", k.redacted()),
}
}

View File

@ -343,6 +343,6 @@ mod test {
.rsa_identity([45; 20].into());
let ids = builder.build().unwrap();
assert_eq!(format!("{}", ids), "ed25519:KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKio $2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d");
assert_eq!(format!("{}", ids.redacted()), "Ki…");
assert_eq!(format!("{}", ids.redacted()), "ed25519:Ki…");
}
}