Expand description
Automatically assert the stability of encoding and mechanisms over time.
This crate provides a unified infrastructure for verifying that implementations maintain backward compatibility by comparing output against known-good hash values stored in TOML files.
§The Conformance Trait
The core abstraction is the Conformance trait, which represents
types that can produce deterministic bytes from a seed.
This enables conformance testing across different domains, for example:
- Codec: Verify wire format stability
- Storage: Verify on-disk format stability
- Network: Verify message ordering consistency
§Storage Format
Test vectors are stored in a TOML file with a single hash per type:
["Vec<u8>"]
n_cases = 100
hash = "abc123..."
["Vec<u16>"]
n_cases = 100
hash = "def456..."The hash is computed by generating n_cases commitments (using seeds
0..n_cases), and hashing all the bytes together.
§Regeneration Mode
When cfg(generate_conformance_tests) is set, tests regenerate their
expected hashes in the TOML file. Use this to intentionally update
the format:
RUSTFLAGS="--cfg generate_conformance_tests" cargo testMacros§
- conformance_
tests - Define tests for types implementing the
Conformancetrait.
Structs§
- Conformance
File - A conformance test file containing test data for multiple types.
- Type
Entry - Conformance test data for a single type.
Enums§
- Conformance
Error - Errors that can occur when loading conformance files.
Constants§
- DEFAULT_
CASES - Default number of test cases when not explicitly specified.
Traits§
- Conformance
- Trait for types that can produce deterministic bytes for conformance testing.
Functions§
- compute_
conformance_ hash - Compute the conformance hash for a type using the
Conformancetrait. - run_
conformance_ test - Run conformance tests using the
Conformancetrait.