Skip to main content

Module daemon

Module daemon 

Source
Expand description

MockDaemon — the daemon side of §7.3, in this process.

Blueprint §9.1 lists init_testing (in-process daemon for unit tests) as part of the node API’s surface. This is that daemon. It is not a stub: it speaks the real greeting (§7.2), the real NodeRequest/NodeEvent families (§7.3), over the real frame codec (§7.1), on both ends of a tokio::io::duplex pair. A node under test cannot tell it from a socket, which is the entire point — a test that passes here is a test of the code that ships.

  Node ──► real greeting ──► real frames ──► MockDaemon
                                                 │
                                       routing table from the specs
                                                 │
  another Node ◄── real NodeEvent frames ◄───────┘

§What it does

RequestAnswer
RegisterRegistered { spec, session }
SubscribeRecorded; inputs start flowing
SendMessageRecorded, and routed to every consumer whose InputSpec::source names that port
OutputDone / CloseOutputsInputClosed to those consumers
ExtStore / ExtLoad / ExtDropAn in-memory extension table; ExtLoad answers ExtValue
RouteUpgradeAckRecorded, so a test can assert the §6.3 handshake completed

The routing is what makes a two-node test possible: connect a producer and a consumer whose input names the producer’s port, and a send on one arrives as an Event::Input on the other, through the wire, exactly as it would through a daemon.

Structs§

MockDaemon
An in-process daemon for unit tests.
RecordedRequest
One request the daemon received, with the node it came from.
RecordedSend
One message a node published.
UnixEndpointUnix
A listening Unix-domain socket, unlinked when it is dropped.

Constants§

DUPLEX_BUFFER
The duplex buffer each mock connection gets.
HANDSHAKE_TIMEOUT
How long the mock greeting is allowed to take.