Skip to content

Commit

Permalink
Unit tests for Signature
Browse files Browse the repository at this point in the history
  • Loading branch information
CyonAlexRDX committed Feb 19, 2024
1 parent 1731692 commit 3d286fc
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/core/types/signatures/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,44 @@ impl From<Ed25519Signature> for Signature {
Self::Ed25519 { value: signature }
}
}

impl HasPlaceholder for Signature {
fn placeholder() -> Self {
Ed25519Signature::placeholder().into()
}

fn placeholder_other() -> Self {
Secp256k1Signature::placeholder().into()
}
}

#[cfg(test)]
mod tests {
use super::*;

#[allow(clippy::upper_case_acronyms)]
type SUT = Signature;

#[test]
fn equality() {
assert_eq!(SUT::placeholder(), SUT::placeholder());
assert_eq!(SUT::placeholder_other(), SUT::placeholder_other());
}

#[test]
fn inequality() {
assert_ne!(SUT::placeholder(), SUT::placeholder_other());
}

#[test]
fn enum_as_inner() {
assert_eq!(
SUT::placeholder().as_ed25519().unwrap(),
&Ed25519Signature::placeholder()
);
assert_eq!(
SUT::placeholder_other().as_secp256k1().unwrap(),
&Secp256k1Signature::placeholder()
);
}
}

0 comments on commit 3d286fc

Please sign in to comment.