Skip to main content

Crate native_ipc_testkit

Crate native_ipc_testkit 

Source
Expand description

§native-ipc-testkit

Deterministic hostile-input generators and golden-message helpers for testing protocols built on native-ipc-core.

The helpers are deliberately bounded so they are suitable for ordinary unit tests and CI, not only fuzzing jobs.

§Example

use native_ipc_testkit::{
    HOSTILE_U64_BOUNDARIES, bounded_bit_mutations, every_truncation,
};

let canonical = b"NIPC";
let truncations: Vec<_> = every_truncation(canonical).collect();
assert_eq!(truncations.first().unwrap().len(), 0);
assert_eq!(truncations.last().unwrap(), canonical);

let mutations = bounded_bit_mutations(canonical, 2);
assert_eq!(mutations.len(), 2);
assert_ne!(mutations[0], canonical);
assert_eq!(HOSTILE_U64_BOUNDARIES.last(), Some(&u64::MAX));

Additional helpers produce fixed-field shared-layout mutations and exactly sized encoded golden vectors. The committed cross-platform fixtures are in the golden_vectors integration test. The same bounded corpus API is runnable as the hostile_inputs example.

Licensed under MIT or Apache-2.0.

Constants§

HOSTILE_U64_BOUNDARIES
Boundary values for hostile relative-offset and declared-length corpora.

Functions§

bounded_bit_mutations
Produces at most limit deterministic one-bit hostile mutations.
every_truncation
Produces truncations of input, including the empty and complete input.
golden_message
Encodes a message into an exactly sized owned golden vector.
hostile_layout_mutations
Produces bounded hostile region-header/layout mutations at fixed fields.