FakeRaftNode
A test double for RaftNode with driver helpers for driving role transitions, injecting committed entries, emitting trace events, and inspecting outgoing proposals.
Defaults make FakeRaftNode() ready to use in one line:
val node = FakeRaftNode()
node.setRole(RaftRole.Leader)
val entry = node.propose("set x=1".encodeToByteArray())
val committed = node.committed.first() as Committed.Entry
// committed.entry.command == "set x=1".encodeToByteArray()Stream semantics — a deliberate divergence from the real RaftNode. The real RaftNode documents committed and trace as hot, no-replay flows (late collectors miss history). For test ergonomics this double backs them with unbounded-buffering channels instead, so pushCommitted(...) followed by committed.first() works without racing a collector. Two consequences a consumer should not encode as RaftNode guarantees:
Constructors
Properties
Behavior of propose. Defaults to contract-faithful: throws NotLeaderException unless role is RaftRole.Leader, otherwise appends the command to committed and returns the resulting LogEntry.
Snapshot publish channel — present to satisfy RaftNode. This double runs no real compaction loop, so setting it has no functional effect; drive setCompactionFloor to simulate a floor and pushInstall to inject a Committed.Install on the committed stream.
Functions
Push a Committed.Install onto committed, advancing compactionFloor and commitIndex to snapshot's throughIndex — the test-double analogue of the engine accepting an InstallSnapshot.
Set commitIndex to index. Does not push any entry onto committed.
Set compactionFloor to index without emitting a Committed.Install.