matklad
Read post

256 Lines or Less: Test Case Minimization

A walkthrough of building a minimal property-based testing (PBT) library in ~256 lines of Zig, centered on a Finite Random Number Generator (FRNG) abstraction. The key insight is that by pre-generating entropy as a fixed byte slice, you can binary-search for the smallest entropy size that reproduces a failure — effectively minimizing test cases without any knowledge of the system under test. The post covers FRNG primitives (bytes, integers, booleans, bounded ranges, weighted random selection), a simulation harness that feeds entropy to a system under test via stdin in a child process, and a search driver that doubles/halves entropy size to find the minimal failing seed. The approach was used to discover a deep algorithmic flaw in a consensus algorithm implementation.

    #distributed-systems#zig
Apr 20•13m read time•From matklad.github.io
Post cover image
Table of contents
FRNGSimulationStepping And RunnigBinary Search the AnswerThe Searcher
231 Impressions
matklad's image
matklad

Matthias Noback's expertise in PHP and domain-driven design (DDD) offers readers insights into buil...

29 Followers

•

437 Upvotes

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard