@rotorsoft/act-tck 1.41.2 → 1.41.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1263,6 +1263,41 @@ var runStoreTck = (options) => {
1263
1263
  await store.commit(s, [], make_meta({ stream: s }), 0)
1264
1264
  ).toEqual([]);
1265
1265
  });
1266
+ it7("takes concurrent commits, reads and writes on one instance", async () => {
1267
+ const x = `commit-concurrent-x-${uid()}`;
1268
+ const y = `commit-concurrent-y-${uid()}`;
1269
+ const [first, second, other, read, subscribed] = await Promise.allSettled([
1270
+ store.commit(
1271
+ x,
1272
+ [inc(1)],
1273
+ make_meta({ stream: x }),
1274
+ -1
1275
+ ),
1276
+ store.commit(
1277
+ x,
1278
+ [inc(2)],
1279
+ make_meta({ stream: x }),
1280
+ -1
1281
+ ),
1282
+ store.commit(y, [inc(1)], make_meta({ stream: y })),
1283
+ store.query(() => {
1284
+ }, { stream: x, stream_exact: true }),
1285
+ // A source nothing writes, so later claims never see it.
1286
+ store.subscribe([
1287
+ { stream: `${y}-idle`, source: `${y}-no-source` }
1288
+ ])
1289
+ ]);
1290
+ expect8(
1291
+ [first, second].filter((r) => r.status === "fulfilled")
1292
+ ).toHaveLength(1);
1293
+ const lost = [first, second].find((r) => r.status === "rejected");
1294
+ expect8(lost.reason).toBeInstanceOf(
1295
+ ConcurrencyError
1296
+ );
1297
+ expect8(other.status).toBe("fulfilled");
1298
+ expect8(read.status).toBe("fulfilled");
1299
+ expect8(subscribed.status).toBe("fulfilled");
1300
+ });
1266
1301
  it7("preserves prior events when a concurrent commit is rejected", async () => {
1267
1302
  const s = `commit-cc-preserve-${uid()}`;
1268
1303
  await store.commit(