Skip to content

Commit f7bc82d

Browse files
Update RTLM4 to make reset-to-zero-value clear clearTimeserial per spec 26bda6ffabfe648c9784215ee79e668201c441b8
1 parent 355344e commit f7bc82d

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

Sources/AblyLiveObjects/Internal/InternalDefaultLiveMap.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,7 @@ internal final class InternalDefaultLiveMap: Sendable {
957957
mutating func resetDataToZeroValued() {
958958
// RTLM4
959959
data = [:]
960+
clearTimeserial = nil
960961
}
961962

962963
/// Releases entries that were tombstoned more than `gracePeriod` ago, per RTLM19.

Tests/AblyLiveObjectsTests/InternalDefaultRealtimeObjectsTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,11 @@ struct InternalDefaultRealtimeObjectsTests {
439439
let originalPool = realtimeObjects.testsOnly_objectsPool
440440
#expect(Set(originalPool.root.testsOnly_data.keys) == ["existingMap", "existingCounter"])
441441

442+
// Give root a non-nil clearTimeserial so we can verify it gets nilled out per RTLM4
443+
// (using a serial before the entry timeserials so entries survive)
444+
_ = originalPool.root.testsOnly_applyMapClearOperation(serial: "aaa")
445+
#expect(originalPool.root.testsOnly_clearTimeserial == "aaa")
446+
442447
let rootSubscriber = Subscriber<DefaultLiveMapUpdate, SubscribeResponse>(callbackQueue: .main)
443448
let coreSDK = MockCoreSDK(channelState: .attached, internalQueue: internalQueue)
444449
try originalPool.root.subscribe(listener: rootSubscriber.createListener(), coreSDK: coreSDK)
@@ -489,6 +494,7 @@ struct InternalDefaultRealtimeObjectsTests {
489494
let newRoot = newPool.root
490495
#expect(newRoot as AnyObject === originalPool.root as AnyObject) // Should be same instance
491496
#expect(newRoot.testsOnly_data.isEmpty) // Should be zero-valued (empty)
497+
#expect(newRoot.testsOnly_clearTimeserial == nil) // RTLM4: zero-value LiveMap has clearTimeserial set to null
492498

493499
// RTO4b3, RTO4b4, RTO4b5: SyncObjectsPool must be cleared, sync sequence cleared, BufferedObjectOperations cleared, appliedOnAckSerials cleared
494500
#expect(!realtimeObjects.testsOnly_hasSyncSequence)

0 commit comments

Comments
 (0)