.
This commit is contained in:
parent
4c002f9acd
commit
b07aa589ff
1 changed files with 728 additions and 530 deletions
|
|
@ -5,7 +5,7 @@ import { test } from "node:test";
|
|||
import type { Database } from "../sync-client/src/persistence/database";
|
||||
import { emptyState } from "../sync-client/src/persistence/database";
|
||||
import { SyncClient } from "../sync-client/src/sync-client";
|
||||
import { toStoredSnapshot } from "../sync-client/src/sync-operations/content";
|
||||
import { toStoredSnapshot } from "../sync-client/src/snapshot";
|
||||
import { EventListeners } from "../sync-client/src/utils/data-structures/event-listeners";
|
||||
import type { SyncService } from "../sync-client/src/services/sync-service";
|
||||
import type { WebSocketManager } from "../sync-client/src/services/websocket-manager";
|
||||
|
|
@ -50,8 +50,8 @@ test("ignored untracked ancestor must remain in place", async () => {
|
|||
);
|
||||
await f.disk.userWrite("private", bytes("LOCAL PRIVATE"));
|
||||
await f.settings.setSettings({ ignorePatterns: ["private"] });
|
||||
f.database.state.remoteHeads.a = head("a", 2, "remote");
|
||||
await f.internals.incorporateFileManifest({
|
||||
(f.database.state.documents.a ??= {}).remote = head("a", 2, "remote");
|
||||
await f.internals.reconcile({
|
||||
fileManifestId: 3,
|
||||
entries: { a: "private/note.md" }
|
||||
});
|
||||
|
|
@ -69,8 +69,8 @@ test("oversized untracked file must remain in place", async () => {
|
|||
);
|
||||
await f.disk.userWrite("a.md", bytes("LOCAL OVERSIZED"));
|
||||
await f.settings.setSettings({ maxFileSizeMB: 5 / (1024 * 1024) });
|
||||
f.database.state.remoteHeads.a = head("a", 2, "R");
|
||||
await f.internals.incorporateFileManifest({
|
||||
(f.database.state.documents.a ??= {}).remote = head("a", 2, "R");
|
||||
await f.internals.reconcile({
|
||||
fileManifestId: 3,
|
||||
entries: { a: "a.md" }
|
||||
});
|
||||
|
|
@ -133,7 +133,7 @@ test("rejected unknown success must use submitted content as merge base", async
|
|||
|
||||
test("bootstrap adopts same-path identity even after multiple notifications", async () => {
|
||||
const f = await fixture({});
|
||||
f.database.state.initialized = false;
|
||||
delete f.database.state.lastSeenUpdateId;
|
||||
f.database.state.fileManifest = { fileManifestId: 0, entries: {} };
|
||||
await f.disk.userWrite("a.md", bytes("local a"));
|
||||
await f.syncer.syncLocallyCreatedFile("a.md");
|
||||
|
|
@ -168,7 +168,7 @@ test("oversized remote head must not cause identical stale uploads forever", asy
|
|||
...head("a", 1, "base"),
|
||||
hash: (await toStoredSnapshot({ content: bytes("base") })).hash
|
||||
};
|
||||
f.database.state.remoteHeads.a = head("a", 2, remoteText);
|
||||
(f.database.state.documents.a ??= {}).remote = head("a", 2, remoteText);
|
||||
await f.settings.setSettings({ maxFileSizeMB: 10 / (1024 * 1024) });
|
||||
f.internals.stopped = false;
|
||||
// Even a small local edit must wait until its required remote base is readable.
|
||||
|
|
@ -480,13 +480,13 @@ for (const interrupted of [false, true]) {
|
|||
...head("a", 1, "base"),
|
||||
hash: (await toStoredSnapshot({ content: bytes("base") })).hash
|
||||
};
|
||||
f.database.state.remoteHeads.a = head("a", 1, "base");
|
||||
(f.database.state.documents.a ??= {}).remote = head("a", 1, "base");
|
||||
f.database.state.lastSeenUpdateId = 1;
|
||||
await f.database.save();
|
||||
const saved = f.persistence.snapshot();
|
||||
const catchUp = async () =>
|
||||
f.internals.incorporateEventBatch(
|
||||
await service.getEvents!(f.database.state.lastSeenUpdateId)
|
||||
await service.getEvents!(f.database.state.lastSeenUpdateId!)
|
||||
);
|
||||
if (interrupted) {
|
||||
await assert.rejects(catchUp(), /interrupted page fetch/);
|
||||
|
|
@ -515,8 +515,8 @@ test("an ignored occupant arriving after the scan keeps its path and privacy", a
|
|||
}
|
||||
);
|
||||
await f.settings.setSettings({ ignorePatterns: ["private"] });
|
||||
f.database.state.remoteHeads.a = head("a", 2, "remote");
|
||||
await f.internals.incorporateFileManifest({
|
||||
(f.database.state.documents.a ??= {}).remote = head("a", 2, "remote");
|
||||
await f.internals.reconcile({
|
||||
fileManifestId: 3,
|
||||
entries: { a: "private/note.md" }
|
||||
});
|
||||
|
|
@ -818,10 +818,15 @@ for (const boundary of ["before:save", "durable:save"]) {
|
|||
const { database } = f.client as unknown as { database: Database };
|
||||
await database.commit({
|
||||
...database.state,
|
||||
rejectedManifest: {
|
||||
entries: { retired: "old.md" },
|
||||
message: "retired rejection"
|
||||
}
|
||||
unconfirmed: [{
|
||||
type: "fileManifest",
|
||||
request: {
|
||||
requestId: "rejected",
|
||||
parentFileManifestId: 0,
|
||||
entries: { retired: "old.md" }
|
||||
},
|
||||
rejection: "retired rejection"
|
||||
}]
|
||||
});
|
||||
let saves = 0,
|
||||
failed = false;
|
||||
|
|
|
|||
Loading…
Reference in a new issue