Skip to content

Commit 8627f1f

Browse files
test(server): focus catchup completion regressions
1 parent dd81457 commit 8627f1f

4 files changed

Lines changed: 306 additions & 532 deletions

File tree

‎apps/server/src/rpcInitialItems.memory.test.ts‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,12 @@ it.each(["prefix", "snapshot", "replay"])(
1616
const { stdout } = await execFile(process.execPath, ["--expose-gc", fixture, root, mode]);
1717
const result = JSON.parse(stdout) as {
1818
checkpoints: ReadonlyArray<{ subscriptions: number; retained: number }>;
19-
deliveredBatches: ReadonlyArray<ReadonlyArray<ReadonlyArray<string>>>;
2019
};
2120
expect(
2221
result.checkpoints.map(({ subscriptions, retained }) => ({ subscriptions, retained })),
2322
).toEqual([
2423
{ subscriptions: 2, retained: 0 },
2524
{ subscriptions: 4, retained: 0 },
2625
]);
27-
expect(result.deliveredBatches).toEqual(
28-
Array.from({ length: 4 }, () => [
29-
mode === "prefix"
30-
? ["prefix"]
31-
: [mode === "snapshot" ? "snapshot" : "event", "synchronized"],
32-
]),
33-
);
3426
},
3527
);

‎apps/server/src/testkit/RpcInitialMemory.fixture.mjs‎

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ const refs = [];
2323
const fibers = [];
2424
const checkpoints = [];
2525
const deliveredCounts = [];
26-
const deliveredBatches = [];
2726

2827
function history() {
2928
const value = JSON.parse(JSON.stringify({ text: NodeCrypto.randomBytes(bytes).toString("hex") }));
@@ -33,7 +32,6 @@ function history() {
3332

3433
function start(ready) {
3534
const index = deliveredCounts.push(0) - 1;
36-
deliveredBatches.push([]);
3735
const live = Stream.fromEffect(Deferred.succeed(ready, undefined)).pipe(
3836
Stream.drain,
3937
Stream.concat(Stream.never),
@@ -82,22 +80,19 @@ function start(ready) {
8280
return stream.pipe(
8381
Effect.flatMap((stream) =>
8482
stream.pipe(
85-
Stream.runForEachArray((items) =>
83+
Stream.runForEach((item) =>
8684
Effect.sync(() => {
87-
deliveredBatches[index].push(items.map((item) => item.kind ?? "prefix"));
88-
for (const item of items) {
89-
if (mode === "prefix") {
90-
NodeAssert.equal(item.text.length, bytes * 2);
91-
} else if (delivered === 0) {
92-
NodeAssert.equal(item.kind, mode === "replay" ? "event" : "snapshot");
93-
const value = mode === "replay" ? item.event.payload : item.projection.messages[0];
94-
NodeAssert.equal(value.text.length, bytes * 2);
95-
} else {
96-
NodeAssert.equal(item.kind, "synchronized");
97-
}
98-
delivered++;
99-
deliveredCounts[index] = delivered;
85+
if (mode === "prefix") {
86+
NodeAssert.equal(item.text.length, bytes * 2);
87+
} else if (delivered === 0) {
88+
NodeAssert.equal(item.kind, mode === "replay" ? "event" : "snapshot");
89+
const value = mode === "replay" ? item.event.payload : item.projection.messages[0];
90+
NodeAssert.equal(value.text.length, bytes * 2);
91+
} else {
92+
NodeAssert.equal(item.kind, "synchronized");
10093
}
94+
delivered++;
95+
deliveredCounts[index] = delivered;
10196
}),
10297
),
10398
Effect.forkDetach,
@@ -129,7 +124,7 @@ const result = await Effect.runPromise(
129124
}
130125
}
131126
for (const fiber of fibers) yield* Fiber.interrupt(fiber);
132-
return { checkpoints, deliveredBatches };
127+
return { checkpoints };
133128
}),
134129
);
135130
console.log(JSON.stringify(result));

0 commit comments

Comments
 (0)