Clean up deterministic tests

This commit is contained in:
Andras Schmelczer 2026-03-28 11:12:43 +00:00
commit f36a84b275

View file

@ -1,37 +1,11 @@
import type { ClientState, TestDefinition } from "../test-definition";
import { assert } from "../utils/assert";
function verifyFinalState(state: ClientState): void {
assert(
state.files.size === 1,
`Expected 1 file, got ${state.files.size}`
);
assert(
state.files.has("doc.md"),
`Expected doc.md to exist`
);
const content = state.files.get("doc.md") ?? "";
// After the merge and three rapid updates, "update 3" should be present.
// Earlier updates may be coalesced, but the final state must include the
// last update's content.
assert(
content.includes("update 3"),
`Expected final content to include "update 3", got: "${content}"`
);
}
import type { TestDefinition } from "../test-definition";
export const rapidUpdatesAfterMergeTest: TestDefinition = {
name: "Rapid Sequential Updates After Concurrent Merge",
description:
"Both clients create the same file (triggering a merge). After merge " +
"completes, Client 0 rapidly sends three updates in succession. Each " +
"update must correctly use the content cache to compute diffs against " +
"the right parent version. Tests that the cache stores server content " +
"(not local content) after MergingUpdate.",
"Both clients create the same file offline, triggering a merge on sync. " +
"Client 0 then rapidly sends three updates. Both clients must converge to the final update.",
clients: 2,
steps: [
// Both create at same path (triggers merge)
{ type: "create", client: 0, path: "doc.md", content: "from client 0" },
{ type: "create", client: 1, path: "doc.md", content: "from client 1" },
@ -40,7 +14,6 @@ export const rapidUpdatesAfterMergeTest: TestDefinition = {
{ type: "sync" },
{ type: "barrier" },
// After merge, Client 0 sends rapid sequential updates
{
type: "update",
client: 0,
@ -65,10 +38,11 @@ export const rapidUpdatesAfterMergeTest: TestDefinition = {
},
{ type: "sync", client: 0 },
// Wait for propagation
{ type: "barrier" },
// Both clients must converge with update 3
{ type: "assert-consistent", verify: verifyFinalState }
{
type: "assert-consistent",
verify: (s) => s.assertFileCount(1).assertContains("doc.md", "update 3"),
}
]
};