Skip to content

Add property-based and fuzz testing for codecs and stream resynchronization #12

Description

@wuisabel-gif

Summary

Add property-based and fuzz tests for the Python, Rust, and C codec surfaces, with particular focus on malformed frames and stream resynchronization.

Motivation

The existing golden vectors verify known examples, but malformed inputs and arbitrary byte streams have a much larger state space. Property-based and fuzz testing can uncover length-field errors, integer boundary problems, parser hangs, inconsistent rejection behavior, and cases where corruption causes unnecessary loss of later valid frames.

Proposed properties

  • Decoding arbitrary bytes never crashes, hangs, or performs unbounded allocation.
  • Valid packets survive decode(encode(packet)) round trips.
  • Frames with invalid CRCs are never accepted.
  • Python, C, and Rust agree on valid and invalid corpus entries.
  • A stream receiver eventually recovers after arbitrary garbage followed by a valid frame.
  • Corrupt input cannot prevent later complete valid frames from being recovered indefinitely.
  • Boundary values for packet size, counts, timestamps, and sequence wraparound behave consistently.

Proposed scope

  • Use Hypothesis for the Python codec and stream receiver.
  • Use proptest or cargo-fuzz for Rust.
  • Add a C fuzz target compatible with libFuzzer or AFL++.
  • Maintain a small shared regression corpus for interesting failures.
  • Run bounded property tests in normal CI and deeper fuzzing in a scheduled workflow.

Acceptance criteria

  • Python property tests cover valid packet generation and arbitrary byte streams.
  • At least one native fuzz target is available for the C or Rust decoder.
  • CI runs a deterministic, time-bounded test configuration.
  • Discovered failures can be saved as shared regression corpus entries.
  • Documentation explains how to run longer fuzz sessions locally.
  • Sanitizers are enabled for native fuzz targets where supported.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions