FakeRoom
A test double for Room with test-driver helpers for roster manipulation, event delivery, and outgoing-frame inspection.
Defaults make FakeRoom() a ready-to-use, host-role, empty-roster room in one line:
val room = FakeRoom()
room.addMember(Member(PeerId("alice"), identity("alice"), Liveness.Connected))
room.deliver(PeerId("alice"), byteArrayOf(1, 2, 3))
val frame = room.incoming.first()For wired two-room scenarios, prefer fakeRoomPair which cross-wires broadcast delivery between two rooms.
Send semantics (matching the Room contract):
broadcast and sendTo after leave are silent no-ops (matching the contract's behaviour after MembershipEvent.HostLost).
Stream semantics — a deliberate divergence from the real Room. The real Room documents events and incoming as hot, no-replay streams (late collectors miss history). For test ergonomics this double backs them with unbounded buffering channels instead, so deliver(...) followed by incoming.first() works without racing a collector. Two consequences a consumer should not encode as Room guarantees:
Constructors
Types
A Seam view returned by FakeRoom.channel.
Properties
All payloads passed to broadcast, in call order.
Configurable result returned by resume. Defaults to ResumeResult.Success.
Functions
Add member to the roster and emit MembershipEvent.Joined.
Returns a Seam view scoped to channel id, backed by _rosterPeers for admit-gated peer visibility and a dedicated Channel
Returns the FakeChannelSeam for id if it has been created, or null otherwise.
Push a raw MembershipEvent onto the events channel. Useful for events not covered by the named helpers.
Emit MembershipEvent.Resumed for peerId (a partitioned joiner has reconnected within the window).
Emit MembershipEvent.WindowOpened (host-side signal that a joiner's reconnect window has opened, expiring at expiresAt).
Flip the named member's Liveness to Liveness.Partitioned and emit MembershipEvent.Partitioned.
Flip the named member's Liveness back to Liveness.Connected and emit MembershipEvent.Recovered.
Remove the member with peerId from the roster and emit MembershipEvent.Left. No-op if the peer is not in the roster.
Update resumeToken.
Transition the seam state to SeamState.Torn. Channel views forward state from _seamState, so tearing the seam winds down any us.tractat.kuilt.crdt.replicator.Quilter subscribed to the channel.