Clean up deterministic tests
This commit is contained in:
parent
7b9287ca52
commit
f36a84b275
1 changed files with 1366 additions and 3835 deletions
|
|
@ -1,32 +1,8 @@
|
|||
import type { ClientState, TestDefinition } from "../test-definition";
|
||||
import { assert } from "../utils/assert";
|
||||
|
||||
function verifyConflictResolution(state: ClientState): void {
|
||||
const files = Array.from(state.files.keys());
|
||||
|
||||
// B.md should exist (client 1 renamed A.md to B.md, and client 0
|
||||
// created B.md with same content — the server merges them)
|
||||
assert(
|
||||
state.files.has("B.md"),
|
||||
`Expected B.md to exist, got: ${files.join(", ")}`
|
||||
);
|
||||
assert(
|
||||
state.files.get("B.md") === "hi",
|
||||
`Expected B.md to have "hi", got: "${state.files.get("B.md")}"`
|
||||
);
|
||||
|
||||
// A.md should not exist (it was renamed to B.md)
|
||||
assert(
|
||||
!state.files.has("A.md"),
|
||||
`A.md should not exist after rename, got: ${files.join(", ")}`
|
||||
);
|
||||
}
|
||||
import type { TestDefinition } from "../test-definition";
|
||||
|
||||
export const renameCreateConflictTest: TestDefinition = {
|
||||
name: "Rename-Create Conflict",
|
||||
description:
|
||||
"Client 0 creates file A, Client 1 renames A to B, then Client 0 (without syncing) creates B. " +
|
||||
"The system must resolve the conflict deterministically.",
|
||||
"Client 0 creates A.md and syncs. Client 1 renames A.md to B.md and syncs. Client 0 (offline) creates B.md with the same content. After reconnecting, both clients should converge with only B.md.",
|
||||
clients: 2,
|
||||
steps: [
|
||||
{ type: "enable-sync", client: 0 },
|
||||
|
|
@ -34,8 +10,10 @@ export const renameCreateConflictTest: TestDefinition = {
|
|||
{ type: "create", client: 0, path: "A.md", content: "hi" },
|
||||
{ type: "sync", client: 0 },
|
||||
{ type: "sync", client: 1 },
|
||||
{ type: "assert-exists", client: 1, path: "A.md" },
|
||||
{ type: "assert-content", client: 1, path: "A.md", content: "hi" },
|
||||
{
|
||||
type: "assert-consistent",
|
||||
verify: (s) => s.assertContent("A.md", "hi"),
|
||||
},
|
||||
{ type: "disable-sync", client: 0 },
|
||||
{ type: "rename", client: 1, oldPath: "A.md", newPath: "B.md" },
|
||||
{ type: "sync", client: 1 },
|
||||
|
|
@ -43,6 +21,10 @@ export const renameCreateConflictTest: TestDefinition = {
|
|||
{ type: "enable-sync", client: 0 },
|
||||
{ type: "sync", client: 0 },
|
||||
{ type: "barrier" },
|
||||
{ type: "assert-consistent", verify: verifyConflictResolution }
|
||||
{
|
||||
type: "assert-consistent",
|
||||
verify: (s) =>
|
||||
s.assertFileNotExists("A.md").assertContent("B.md", "hi"),
|
||||
}
|
||||
]
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue