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.
Functions
Returns a fresh, empty RaftStorage instance.
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.