792f2f174b
The 32-byte test key "0123456789abcdef0123456789abcdef" was hardcoded in three places: src/crypto.rs unit tests, tests/roundtrip.rs, and tests/library_api.rs - three copies to keep in sync if the fixture ever changes. Add tests/common/mod.rs exposing the KEY bytes and a test_key() SecretBytes32 constructor; roundtrip.rs and library_api.rs now pull from it. The unit tests in src/crypto.rs cannot reach an integration-test module and keep their own copy. The module carries #![allow(dead_code)] because each test crate compiles its own copy and none uses every fixture. Test-only change. Test plan: cargo test passes all suites (43 CLI roundtrip tests, 2 library_api tests, 13 unit tests).
21 lines
700 B
Rust
21 lines
700 B
Rust
// SPDX-License-Identifier: MIT-0
|
|
//
|
|
// Fixtures shared by the integration-test crates (tests/*.rs). The unit
|
|
// tests inside src/ cannot reach this module and keep their own copies.
|
|
|
|
// Each test crate compiles its own copy of this module and not every crate
|
|
// uses every fixture, so the dead-code lint misfires here.
|
|
#![allow(dead_code)]
|
|
|
|
use fcry::SecretBytes32;
|
|
|
|
/// The raw 32-byte key used by all integration tests.
|
|
pub const KEY: &[u8; 32] = b"0123456789abcdef0123456789abcdef";
|
|
|
|
/// [`KEY`] wrapped in the `SecretBytes32` the library API takes.
|
|
pub fn test_key() -> SecretBytes32 {
|
|
let mut key = SecretBytes32::zeroed();
|
|
key.with_mut_array(|key| key.copy_from_slice(KEY));
|
|
key
|
|
}
|