Skip to content

Commit 69bb07f

Browse files
feat(keys): added coverage for FinalizedEpoch::verify_signature map_errs (#397)
* verify_signatures mapp_errs tested * Made it look prettier * added matches --------- Co-authored-by: Ryan <ryan@deltadevs.xyz>
1 parent adbd0dd commit 69bb07f

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

crates/keys/src/tests/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#[cfg(test)]
22
mod key_tests {
3+
use crate::errors::{CryptoError, VerificationError};
34
use ed25519_consensus::SigningKey as Ed25519SigningKey;
45
use prism_serde::base64::{FromBase64, ToBase64};
56
use rand::rngs::OsRng;
@@ -346,6 +347,28 @@ mod key_tests {
346347
assert!(result.is_err());
347348
}
348349

350+
#[test]
351+
fn test_verifying_key_with_invalid_bytes() {
352+
let invalid_bytes = [0u8; 1];
353+
354+
let algorithms = [
355+
CryptoAlgorithm::Ed25519,
356+
CryptoAlgorithm::Secp256k1,
357+
CryptoAlgorithm::Secp256r1,
358+
CryptoAlgorithm::Eip191,
359+
CryptoAlgorithm::CosmosAdr36,
360+
];
361+
362+
for algorithm in algorithms {
363+
let result = VerifyingKey::from_algorithm_and_bytes(algorithm, &invalid_bytes);
364+
assert!(matches!(
365+
result,
366+
Err(CryptoError::VerificationError(
367+
VerificationError::VerifyError(_, _)
368+
))
369+
));
370+
}
371+
349372
#[test]
350373
fn test_verifying_key_from_spki_pem_path_or_base64() {
351374
let temp_dir = tempdir().unwrap();

0 commit comments

Comments
 (0)