Skip to content

Commit

Permalink
Fully qualify Error to simplify imports
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaseizinger committed Nov 11, 2021
1 parent 8e96aba commit 52d0554
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,7 @@ mod tests {
use key::{SecretKey, PublicKey};
use super::{from_hex, to_hex};
use super::constants;
use super::{Secp256k1, Signature, Message};
use super::Error::{InvalidMessage, IncorrectSignature, InvalidSignature};
use super::{Secp256k1, Signature, Message, Error};
use ffi::{self, types::AlignedType};
use context::*;

Expand Down Expand Up @@ -1193,20 +1192,20 @@ mod tests {
let mut msg = [0u8; 32];
thread_rng().fill_bytes(&mut msg);
let msg = Message::from_slice(&msg).unwrap();
assert_eq!(s.verify(&msg, &sig, &pk), Err(IncorrectSignature));
assert_eq!(s.verify(&msg, &sig, &pk), Err(Error::IncorrectSignature));
}

#[test]
fn test_bad_slice() {
assert_eq!(Signature::from_der(&[0; constants::MAX_SIGNATURE_SIZE + 1]),
Err(InvalidSignature));
Err(Error::InvalidSignature));
assert_eq!(Signature::from_der(&[0; constants::MAX_SIGNATURE_SIZE]),
Err(InvalidSignature));
Err(Error::InvalidSignature));

assert_eq!(Message::from_slice(&[0; constants::MESSAGE_SIZE - 1]),
Err(InvalidMessage));
Err(Error::InvalidMessage));
assert_eq!(Message::from_slice(&[0; constants::MESSAGE_SIZE + 1]),
Err(InvalidMessage));
Err(Error::InvalidMessage));
assert!(Message::from_slice(&[0; constants::MESSAGE_SIZE]).is_ok());
assert!(Message::from_slice(&[1; constants::MESSAGE_SIZE]).is_ok());
}
Expand Down Expand Up @@ -1253,7 +1252,7 @@ mod tests {
let msg = Message::from_slice(&msg[..]).unwrap();

// without normalization we expect this will fail
assert_eq!(secp.verify(&msg, &sig, &pk), Err(IncorrectSignature));
assert_eq!(secp.verify(&msg, &sig, &pk), Err(Error::IncorrectSignature));
// after normalization it should pass
sig.normalize_s();
assert_eq!(secp.verify(&msg, &sig, &pk), Ok(()));
Expand Down

0 comments on commit 52d0554

Please sign in to comment.