Package-level declarations
Types
Structure-unaware mutations of byte strings, for fuzz tests of decoders: bit flips, replaced, inserted and deleted bytes, duplicated prefixes and truncation. Start from valid encodings (RFC test vectors are ideal seeds) so mutations reach deep into the parser, and use a seeded Random so a failure reproduces.
What an InMemoryNetwork did with a datagram.
A byte stream side; writes arrive in pieces of at most the chunk size.
One side of an in-memory connection, for fault injection. Closing either side ends both: the other reads what is already on its way, then the end of the stream.
Accepts the connections InMemoryConnections.connector opens to its address.
Thrown by InMemoryConnections.connector when nobody listens at peer.
Thrown when reading from a connection that InMemoryConnection.reset broke.
In-memory connections for tests of CoAP over reliable transports (RFC 8323): listen binds a listener at an address, and connector connects to it, with a byte stream for coap+tcp and coaps+tcp or a message stream for coap+ws and coaps+ws. Delivery is immediate, ordered and lossless, as the transports promise; what a test needs beyond that it injects: InMemoryConnection.inject hands raw bytes to a side as if its peer had sent them, InMemoryConnection.reset breaks a connection.
A datagram on its way through an InMemoryNetwork. bytes is the sender's copy; do not modify it.
One of the two ways a CoAP endpoint reaches a peer, in memory, so that one test runs over both and checks that the exchanges behave the same: Datagrams on an InMemoryNetwork (RFC 7252), Connections on InMemoryConnections (RFC 8323).
A message stream side; every message arrives whole, as a WebSocket frame.
A simulated datagram network for tests: every InMemoryTransport attached to it gets a UDP-style address and exchanges datagrams with the others in memory.
A stand-in for a DTLS layer on an InMemoryTransport, for tests of what a CoAP endpoint does with secure sessions: every peer appears as an Endpoint.Secure, one session per address, authenticated as identity, and nothing is encrypted. endAll ends every session at once, as a DTLS layer reports sessions that closed (DatagramEvent.SessionEnded, RFC 7252 §9.1.1); a send to an ended session throws SessionEndedException, and the next datagram to or from the address opens a new session. Safe to use from any coroutine.
A DatagramTransport attached to an InMemoryNetwork at localEndpoint. Obtain one from InMemoryNetwork.attach.
How an InMemoryNetwork treats each datagram: it may lose it, deliver it twice, or deliver it late. Different delays for consecutive datagrams reorder them, which is how reordering is simulated.
A DatagramTransport whose source address changes in the middle of a conversation, as a NAT rebinding does to a client behind it: datagrams go out from first until switchAt of them were sent, and from second after that, so the peer sees the later ones come from another address. Datagrams arrive on both addresses, unless oldAddressReceives is false: then whatever reaches first after the switch is lost, as when the old NAT binding has expired.
Concurrency stress tests on real threads. Everything runs on Dispatchers.Default: a thread pool on the JVM and Kotlin/Native, the single event loop on JS and Wasm. The same common test therefore races threads where the platform has them, and interleaves at suspension points where it does not.
One iteration of Stress.run: a CoroutineScope whose coroutines the iteration waits for, the iteration's number, and a background scope for coroutines that outlive the body, such as those of an endpoint, like runTest's backgroundScope.