mirror of
https://github.com/lux-apps/papers.git
synced 2026-10-30 18:15:21 +00:00
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.
40 lines
1.2 KiB
TeX
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}
|
|
|
|
%% ============================================================
|