RaftStorageConformanceSuite

Reusable contract test suite for RaftStorage implementations.

Subclass and implement newStorage to bind any storage under test. Every Test in this class encodes a required invariant of the RaftStorage contract — a conforming implementation must pass all of them.

Lives in commonMain of :kuilt-conformance (not a module's commonTest) so every storage adapter can subclass it from its own test source set.

class SqliteRaftStorageConformanceTest : RaftStorageConformanceSuite() {
override fun newStorage(): RaftStorage = SqliteRaftStorage(inMemoryDb())
}

newStorage must return a fresh, empty instance on every call — term 0, no vote, empty log.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun appendAfterTruncate_works(): TestResult
Link copied to clipboard
fun appendsAndRetrievesEntries(): TestResult
Link copied to clipboard
fun entriesFromIndex_filters(): TestResult
Link copied to clipboard
fun entriesOnEmptyLog_isEmpty(): TestResult
Link copied to clipboard
fun initialTermIsZero(): TestResult
Link copied to clipboard
fun initialVotedForIsNull(): TestResult
Link copied to clipboard
abstract fun newStorage(): RaftStorage

Returns a fresh, empty RaftStorage instance.

Link copied to clipboard
fun savesAndLoadsTerm(): TestResult
Link copied to clipboard
fun savesAndLoadsVotedFor(): TestResult
Link copied to clipboard

Verifies the §5.1/§5.2 atomicity contract: after RaftStorage.saveTermAndVotedFor both term and votedFor are visible together. Persistent implementations must write both in a single transaction so a mid-write crash cannot leave a node with an advanced term but stale vote (or vice-versa), which would allow it to vote twice in the same term.

Link copied to clipboard
Link copied to clipboard
fun saveVotedForNull_clearsVote(): TestResult
Link copied to clipboard