Here I'd recommend to test not only the output length but also its content (by checking that the result is identical to the expected one):
|
#[cfg(test)] |
|
mod generating_pseudorandom_bytes { |
|
use super::*; |
|
|
|
// TODO: 10,000 is the wrong number, @aniap what is correct here? |
|
#[test] |
|
fn it_generates_output_of_size_10000() { |
|
let key: [u8; STREAM_CIPHER_KEY_SIZE] = |
|
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; |
|
let iv: [u8; STREAM_CIPHER_KEY_SIZE] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; |
|
|
|
let rand_bytes = generate_pseudorandom_bytes(&key, &iv, 10000); |
|
assert_eq!(10000, rand_bytes.len()); |
|
} |
|
} |
Also, it's usually better to use input values other than all-zero (or all-some-constant) to detect potential endianness and byte ordering issues.
Here I'd recommend to test not only the output length but also its content (by checking that the result is identical to the expected one):
sphinx/src/crypto/mod.rs
Lines 62 to 76 in b168f70
Also, it's usually better to use input values other than all-zero (or all-some-constant) to detect potential endianness and byte ordering issues.