Skip to main content

Module mock

Module mock 

Source
Expand description

MockRuntime (feature runtime-mock): virtual time and an in-memory network, so that driven connections run deterministically and a 30-second timeout takes no wall time.

  • Clock. MockRuntime::now starts at the moment the runtime was made and moves only when told: MockClock::advance by hand, or, inside MockRuntime::run (and block_on), to the next timer whenever nothing can run (as tokio’s paused clock does). A timer whose time is reached is woken; what waits on nothing with no timer pending is a deadlock, and run panics saying so instead of hanging.
  • Executor. Tasks run on the thread that calls run, in the order they were woken.
  • Network (MockNet). UDP sockets (multicast included) and TCP listeners and connections between mock sockets, by address: no file descriptor, nothing leaves the process. Each direction between two IP addresses is a link with a delay, a loss rate and a block switch (LinkConfig); loss draws from a seeded generator, so a run is the same every time. A filter can drop chosen datagrams (MockNet::set_filter), and every datagram is logged with its traffic class and fate (MockNet::log). Names resolve from a table (MockNet::add_host). TCP is reliable: its bytes take the link’s delay, never its loss, and a blocked link holds a connection attempt forever.

Structs§

DatagramRecord
One datagram of the MockNet::log.
LinkConfig
One direction between two IP addresses of the MockNet.
MockClock
The virtual clock of a MockRuntime.
MockDatagram
A datagram as the MockNet sees it, for a filter.
MockNet
The in-memory network of a MockRuntime.
MockRuntime
A runtime on virtual time with an in-memory network (see the module documentation).

Enums§

Fate
What became of a datagram.

Type Aliases§

DatagramFilter
A filter of the MockNet: false drops the datagram.