Move helper function below usage

This is not C89. We can declare the more important things first.
This commit is contained in:
Thomas Eizinger 2021-09-09 20:01:59 +10:00
parent ce4427747d
commit c5c95513f2
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96
1 changed files with 19 additions and 19 deletions

View File

@ -277,25 +277,6 @@ mod tests {
}};
}
fn test_schnorrsig_sign_helper(
sign: fn(&Secp256k1<All>, &Message, &KeyPair, &mut ThreadRng) -> Signature,
) {
let secp = Secp256k1::new();
let mut rng = thread_rng();
let (seckey, pubkey) = secp.generate_schnorrsig_keypair(&mut rng);
let mut msg = [0u8; 32];
for _ in 0..100 {
rng.fill_bytes(&mut msg);
let msg = Message::from_slice(&msg).unwrap();
let sig = sign(&secp, &msg, &seckey, &mut rng);
assert!(secp.verify_schnorr(&sig, &msg, &pubkey).is_ok());
}
}
#[test]
fn test_schnorrsig_sign_with_aux_rand_verify() {
test_schnorrsig_sign_helper(|secp, msg, seckey, rng| {
@ -326,6 +307,25 @@ mod tests {
})
}
fn test_schnorrsig_sign_helper(
sign: fn(&Secp256k1<All>, &Message, &KeyPair, &mut ThreadRng) -> Signature,
) {
let secp = Secp256k1::new();
let mut rng = thread_rng();
let (seckey, pubkey) = secp.generate_schnorrsig_keypair(&mut rng);
let mut msg = [0u8; 32];
for _ in 0..100 {
rng.fill_bytes(&mut msg);
let msg = Message::from_slice(&msg).unwrap();
let sig = sign(&secp, &msg, &seckey, &mut rng);
assert!(secp.verify_schnorr(&sig, &msg, &pubkey).is_ok());
}
}
#[test]
#[cfg(not(fuzzing))] // fixed sig vectors can't work with fuzz-sigs
fn test_schnorrsig_sign() {