Merge rust-bitcoin/rust-bitcoin#3352: hashes: Put test function in a module

6c0aaa0915 hashes: Put test function in a module (Tobin C. Harding)

Pull request description:

  With a recent nightly toolchain `clippy` gives us an error:

    error: missing documentation for a constant

  I'm not sure why the error is emitted but wrapping the function in a `tests` module as is standard practice clears the error.

ACKs for top commit:
  Kixunil:
    ACK 6c0aaa0915
  apoelstra:
    ACK 6c0aaa0915 successfully ran local tests

Tree-SHA512: f6b72c439d3fb34944b58565afaaeeea9e9420d4031091d0215f8c514b64f4ea593f155363fd173f022739422b504e3b2215ce60b35d55b4fd8a3554c5a84f3c
This commit is contained in:
merge-script 2024-09-13 15:22:09 +00:00
commit d05b6eb34c
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 38 additions and 33 deletions

View File

@ -52,8 +52,12 @@ pub fn fixed_time_eq(a: &[u8], b: &[u8]) -> bool {
unsafe { (::core::ptr::read_volatile(&r) & 1) == 0 }
}
#[test]
fn eq_test() {
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn eq_test() {
assert!(fixed_time_eq(&[0b00000000], &[0b00000000]));
assert!(fixed_time_eq(&[0b00000001], &[0b00000001]));
assert!(fixed_time_eq(&[0b00000010], &[0b00000010]));
@ -87,6 +91,7 @@ fn eq_test() {
assert!(!fixed_time_eq(&[0b00000000, 0b00000001], &[0b00000000, 0b00000000]));
assert!(!fixed_time_eq(&[0b00000000, 0b00000000], &[0b00000001, 0b00000000]));
assert!(!fixed_time_eq(&[0b00000000, 0b00000000], &[0b00000001, 0b00000001]));
}
}
#[cfg(bench)]