RoomConformanceSuite

abstract class RoomConformanceSuite

Reusable contract test suite for RoomFactory implementations.

Subclass and implement newHarness to bind any RoomFactory under test. Every Test encodes a required invariant of the Room lifecycle state machine.

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

Virtual time convention: all partition tests advance in 100 ms steps using fastHeartbeatConfig (interval=100ms, timeout=200ms, reconnectWindow=500ms):

Scope contract: newHarness receives the test's CoroutineScope (typically backgroundScope from runTest) so FaultyLoom and SeamRoomFactory are correctly structured under the test's virtual-time scheduler.

Fault injection: tests that require partition behaviour check RoomHarness.faultyLoom — when null the test is skipped so subclasses backed by fabrics that do not support fault injection still pass the suite.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
data class RoomHarness(val hostFactory: RoomFactory, val joinerFactory: RoomFactory, val faultyLoom: FaultyLoom?, val clock: () -> Instant, val advanceClock: (Long) -> Unit)

A harness that bundles host and joiner RoomFactorys plus optional FaultyLoom for partition tests.

Properties

Link copied to clipboard

Fast heartbeat config shared by all tests so virtual-time advancement is cheap. Advancing 4 × 100 ms triggers MembershipEvent.Partitioned; advancing 9 × 100 ms exhausts the reconnect window (PeerLost / HostLost).

Functions

Link copied to clipboard
fun hostFactoryAssignsHostRole(): TestResult
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun newHarness(scope: CoroutineScope): RoomConformanceSuite.RoomHarness

Provide a fresh RoomHarness for one test, using scope as the coroutine scope for background loops (SeamRoomFactory, FaultyLoom).

Faults only the host's FaultySeam (0) with FaultProfile.DropAll in both directions. The joiner's seam (1) stays Healthy, mirroring us.tractat.kuilt.session.PartitionRoleTest's proven partition/recovery pattern.

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