MultiNodeRaftSim

constructor(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))

Parameters

nodeIds

The ordered list of voter NodeIds forming the initial cluster config.

scope

The test's TestScope — used for withTimeout bounds in the await helpers.

nodeScope

Scope for node coroutines — pass TestScope.backgroundScope so the infinite heartbeat/election loops are cancelled at test teardown without kotlinx.coroutines.test.UncompletedCoroutinesError.

baseConfig

Timing parameters for every node. RaftConfig.random is overridden per node (Random(baseSeed + nodeIndex)) to ensure distinct election timeouts and guarantee convergence. Must have RaftConfig.expectVirtualTime = true for tests running under a kotlinx.coroutines.test.TestDispatcher. Defaults to MULTI_NODE_SIM_BASE_CONFIG.

baseSeed

Seed from which per-node Randoms are derived. Change to explore different election orderings; the default MULTI_NODE_SIM_SEED is stable across runs.

maxPayloadBytes

Optional payload cap forwarded to MultiNodeRaftNetwork — forces InstallSnapshot chunking in tests that exercise the snapshot-transfer path.

nodeFactory

Override to wire a custom RaftNode implementation. The default wires CoroutineScope.raftNode with a per-node seeded config. Parameters: (id, transport, storage, childScope).