Tests
- Tests live next to the code, in
_test.gofiles, mostly as external test packages (package tcp_test). - A module's tests never import
core/. That the contract alone is enough is the point of the design. - Prefer real bytes: the TLS sniffer tests use ClientHellos generated by
crypto/tls; proxy tests run both roles overnet.Pipe; overlay tests run both roles over a loopback TCP pair, which half-closes and has deadlines. - Generate keys and certificates in the test (
crypto/x509), so no key material is ever committed. - Parsers of untrusted bytes get a fuzz target (
go test -fuzz), as the Trojan wire format and the WebSocket frame reader have. - End-to-end tests in
core/builderbuild a server and a client from config files, asapranik rundoes, and carry TCP and UDP through them. - Core tests use small fakes of
specinterfaces (seecore/relay/datagram_test.go) or real UDP sockets on127.0.0.1. - Everything runs under
-race.