Testing
Asynchronous I/O code is notoriously difficult to test. Real network operations introduce latency, non-determinism, and dependencies on external services — all of which make tests slow and fragile. Corosio provides test utilities that replace live networking with controllable, deterministic substitutes. You can stage data for reads, verify what your code writes, and force short reads or writes — all without opening a single network connection. This section covers the tools and patterns that make thorough testing of I/O code practical and repeatable.
What’s in this section
-
Mock Sockets —
mocket,make_mocket_pair, and the staging API for byte-level deterministic tests. -
Socket Pairs —
make_socket_pairfor tests that need real socket semantics (TLS,set_option,shutdown, true EOF). -
Testing Patterns — recipes that combine the two facilities.
Choosing the right tool
| Goal | Use |
|---|---|
Byte-level expectations, staged responses, no real network |
|
Real socket semantics — TLS handshake, |
|
Combine the two (e.g., framing on top of TLS over a real socket) |
See Patterns |