fix complete directory sync for late web clients

This commit is contained in:
illusia committed 2026-09-01 23:32:15 +08:00
1 parent aa5c5e687f
commit d7766497e8
3 files changed
+48 -10

No files matched your search

+13
View File
@@ -31,3 +31,16 @@ test("directory state and movement events remain isolated per session", () => {
assert.deepEqual(first.getSnapshot()?.clients.map((item) => [item.id, item.channelID]), [[3, 2n]]);
assert.deepEqual(second.getSnapshot()?.clients.map((item) => [item.id, item.channelID]), [[3, 1n]]);
});
test("directory synchronizer keeps clients across staged partial snapshots", () => {
const sync = new DirectorySynchronizer();
const alice = client(7, "Alice", 1n);
const bob = client(8, "Bob", 1n);
sync.applySnapshot({ channels: [root], clients: [alice, bob] });
sync.applySnapshot({ channels: [root], clients: [bob] });
assert.deepEqual(sync.getSnapshot()?.clients.map((item) => item.id), [7, 8]);
sync.applyClientLeave(alice.id);
assert.deepEqual(sync.getSnapshot()?.clients.map((item) => item.id), [8]);
});