@rotorsoft/act-tck 1.38.10 → 1.38.12

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
@@ -1116,7 +1116,7 @@ import {
1116
1116
  TOMBSTONE_EVENT,
1117
1117
  ValidationError
1118
1118
  } from "@rotorsoft/act";
1119
- import { afterAll as afterAll4, beforeAll as beforeAll4, describe as describe8, expect as expect8, it as it7 } from "vitest";
1119
+ import { afterAll as afterAll4, beforeAll as beforeAll4, describe as describe8, expect as expect8, it as it7, vi } from "vitest";
1120
1120
  var runStoreTck = (options) => {
1121
1121
  describe8(`TCK / Store / ${options.name}`, () => {
1122
1122
  let store;
@@ -2607,6 +2607,30 @@ var runStoreTck = (options) => {
2607
2607
  expect8(leased.find((l) => l.stream === ctl)).toBeDefined();
2608
2608
  expect8(leased.find((l) => l.stream === s)).toBeUndefined();
2609
2609
  });
2610
+ it7("judges deferred_at by the claiming worker's clock", async () => {
2611
+ const s = `defer-clock-${uid()}`;
2612
+ await store.subscribe([{ stream: s }]);
2613
+ await store.commit(
2614
+ s,
2615
+ [inc(1)],
2616
+ make_meta({ stream: s })
2617
+ );
2618
+ expect8(await store.defer([s], Date.now() + 6e4)).toBe(1);
2619
+ await correlate();
2620
+ vi.useFakeTimers({
2621
+ toFake: ["Date"],
2622
+ shouldAdvanceTime: true,
2623
+ now: Date.now() + 12e4
2624
+ });
2625
+ try {
2626
+ const leased = await store.claim(100, 100, `w-${uid()}`, 1);
2627
+ const mine = leased.find((l) => l.stream === s);
2628
+ expect8(mine).toBeDefined();
2629
+ await store.ack(leased);
2630
+ } finally {
2631
+ vi.useRealTimers();
2632
+ }
2633
+ });
2610
2634
  it7("makes a stream claimable once the deferred_at is in the past", async () => {
2611
2635
  const s = `defer-past-${uid()}`;
2612
2636
  await store.subscribe([{ stream: s }]);
@@ -4478,6 +4502,31 @@ var runStoreTck = (options) => {
4478
4502
  await cache.dispose();
4479
4503
  }
4480
4504
  };
4505
+ it7("resets every correlate checkpoint, since the restored log is renumbered", async () => {
4506
+ const correlator = {
4507
+ key: `k-${uid()}`,
4508
+ by: `w-${uid()}`,
4509
+ millis: 6e4
4510
+ };
4511
+ await store.subscribe([], 50);
4512
+ await store.subscribe([], 50, correlator);
4513
+ expect8((await store.subscribe([])).correlated_at).toBe(50);
4514
+ const s = `restore-cp-${uid()}`;
4515
+ const t = /* @__PURE__ */ new Date("2020-01-01T00:00:00.000Z");
4516
+ const result = await restore(
4517
+ as_source([
4518
+ event(1, s, 0, "Incremented", t, { amount: 1 }),
4519
+ event(2, s, 1, "Incremented", t, { amount: 1 })
4520
+ ])
4521
+ );
4522
+ expect8(result.kept).toBe(2);
4523
+ const restored = await collect(store, { limit: 10 });
4524
+ const min_id = Math.min(...restored.map((e) => e.id));
4525
+ const shared = (await store.subscribe([])).correlated_at;
4526
+ const keyed = (await store.subscribe([], void 0, correlator)).correlated_at;
4527
+ expect8(shared).toBeLessThan(min_id);
4528
+ expect8(keyed).toBeLessThan(min_id);
4529
+ });
4481
4530
  it7("returns kept=0 on an empty source", async () => {
4482
4531
  const result = await restore(as_source([]));
4483
4532
  expect8(result.kept).toBe(0);