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.
44 lines
1.4 KiB
TeX
44 lines
1.4 KiB
TeX
\section{Layer 2: Integration Tests}
|
|
|
|
|
|
Integration tests verify that components work together. The key difference from unit
|
|
tests: multiple components are instantiated (but not the full system).
|
|
|
|
\begin{lstlisting}[language=Go,caption={Integration test for consensus + networking}]
|
|
func TestConsensusWithNetworkDelay(t *testing.T) {
|
|
// Create 4 validators with simulated network
|
|
net := newTestNetwork(4)
|
|
|
|
// Add latency: 50ms per message
|
|
net.SetLatency(50 * time.Millisecond)
|
|
|
|
// Propose a block
|
|
net.Validators[0].Propose(testBlock)
|
|
|
|
// Wait for consensus
|
|
for _, v := range net.Validators {
|
|
select {
|
|
case decision := <-v.Decisions():
|
|
require.Equal(t, testBlock.Hash(), decision.Hash())
|
|
case <-time.After(5 * time.Second):
|
|
t.Fatal("consensus did not complete within 5s")
|
|
}
|
|
}
|
|
}
|
|
\end{lstlisting}
|
|
|
|
\subsection{Simulated Network}
|
|
|
|
Our integration test framework includes a simulated network that supports:
|
|
\begin{itemize}[nosep]
|
|
\item Configurable latency per link.
|
|
\item Message reordering.
|
|
\item Message loss (configurable drop rate).
|
|
\item Partitions (disconnect a subset of nodes from the rest).
|
|
\end{itemize}
|
|
|
|
This is not full Jepsen-style testing (that uses real processes)---it is deterministic
|
|
simulation that runs in milliseconds.
|
|
|
|
%% ============================================================
|