Package-level declarations

Types

Link copied to clipboard
class FakeRaftNode(val selfId: NodeId = NodeId("self"), initialRole: RaftRole = RaftRole.Follower, initialLeader: NodeId? = null, initialCommitIndex: Long = 0, val clientId: ClientId = ClientId.auto(selfId, Random(selfId.value.hashCode())), initialMembership: ClusterConfig = ClusterConfig.ofVoters(listOf(NodeId("self")))) : RaftNode

A test double for RaftNode with driver helpers for driving role transitions, injecting committed entries, emitting trace events, and inspecting outgoing proposals.

Link copied to clipboard
class MultiNodeRaftNetwork(maxPayloadBytes: Int? = null)

An in-process RaftTransport network backed by Channels — the published equivalent of the :kuilt-raft private test network. Obtain a per-node transport via transport; control network partitions via partition, dropLink, and heal.

Link copied to clipboard
class MultiNodeRaftSim(val nodeIds: List<NodeId>, scope: CoroutineScope, nodeScope: CoroutineScope, baseConfig: RaftConfig = MULTI_NODE_SIM_BASE_CONFIG, baseSeed: Long = MULTI_NODE_SIM_SEED, maxPayloadBytes: Int? = null, nodeFactory: (NodeId, RaftTransport, RaftStorage, CoroutineScope) -> RaftNode = defaultNodeFactory(nodeIds, baseConfig, baseSeed))

Multi-node Raft simulation harness for use in tests. See the file-level KDoc for the full determinism contract and setup ceremony.

Properties

Link copied to clipboard

Fast timing config for MultiNodeRaftSim tests — elections fire in single-digit virtual ms, so a 3-node leader election completes in ≤ 20 ms of virtual time.

Link copied to clipboard
const val MULTI_NODE_SIM_SEED: Long = 485

Stable seed for per-node Random derivation in MultiNodeRaftSim. Different from :kuilt-raft's internal test seed (383) so harness tests explore different election orderings independently.

Link copied to clipboard

Wall-clock backstop for raftSimTest — the budget for a genuine wedge, not a performance assertion.

Functions

Link copied to clipboard
suspend fun <T> dumpOnWedge(sim: MultiNodeRaftSim, emit: (String) -> Unit = { println(it) }, body: suspend () -> T): T

Run body, emitting a MultiNodeRaftSim.dumpState snapshot of sim to emit if body is cancelled, then rethrowing the CancellationException untouched.

Link copied to clipboard
fun raftSimTest(n: Int = 3, baseConfig: RaftConfig = MULTI_NODE_SIM_BASE_CONFIG, baseSeed: Long = MULTI_NODE_SIM_SEED, timeout: Duration = RAFT_SIM_WEDGE_BACKSTOP, body: suspend TestScope.(MultiNodeRaftSim) -> Unit): TestResult

Build a MultiNodeRaftSim of n voters and run body under runTest(StandardTestDispatcher(), timeout = RAFT_SIM_WEDGE_BACKSTOP), wrapped in dumpOnWedge — the canonical harness for multi-node Raft tests. See MultiNodeRaftSim for the full determinism contract.