Files
papers/lux-distributed-systems-testing/sections/04-layer-3-property-based-and-fuzz-tests.tex
zeekay 4a753bb639 papers: reorganize into per-paper dirs, add Antje Worring as co-author
Restructured from flat .tex/.pdf files into per-paper subdirectories.
Added Antje Worring as co-author on all papers.
Synced PDFs to pdfs/ for download site.
2026-04-18 21:50:07 -07:00

40 lines
1.2 KiB
TeX

\section{Layer 3: Property-Based and Fuzz Tests}
Covered in detail in our companion paper on fuzzing. Key applications for distributed
systems:
\begin{itemize}[nosep]
\item \textbf{Serialization round-trip}: For every message type, serialize then
deserialize and check equality.
\item \textbf{State machine determinism}: Apply the same sequence of blocks to two
independent state instances and verify identical final states.
\item \textbf{Merkle proof soundness}: For every leaf in a tree, generate and verify
the proof.
\end{itemize}
\begin{lstlisting}[language=Go,caption={Fuzz test for message serialization}]
func FuzzMessageRoundTrip(f *testing.F) {
f.Add([]byte{1, 0, 0, 0}) // PROPOSE type
f.Fuzz(func(t *testing.T, data []byte) {
msg, err := DecodeMessage(data)
if err != nil {
return // Invalid input is fine
}
// Re-encode
encoded := msg.Encode()
// Re-decode
msg2, err := DecodeMessage(encoded)
require.NoError(t, err)
// Must be equal
require.Equal(t, msg, msg2)
})
}
\end{lstlisting}
%% ============================================================