@rotorsoft/act-tck 1.13.0 → 1.13.2

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
@@ -662,6 +662,52 @@ var runStoreTck = (options) => {
662
662
  }
663
663
  });
664
664
  });
665
+ describe4("lease semantics", () => {
666
+ it4("returns retry=0 on first claim and increments on re-claim without ack", async () => {
667
+ const fresh = await options.factory();
668
+ try {
669
+ await fresh.drop();
670
+ await fresh.seed();
671
+ const s = `lease-retry-${uid()}`;
672
+ await fresh.subscribe([{ stream: s }]);
673
+ await fresh.commit(
674
+ s,
675
+ [inc(1)],
676
+ make_meta({ stream: s })
677
+ );
678
+ const first = await fresh.claim(1, 0, `w-${uid()}`, 0);
679
+ const f = first.find((l) => l.stream === s);
680
+ expect4(f).toBeDefined();
681
+ expect4(f.retry).toBe(0);
682
+ const second = await fresh.claim(1, 0, `w-${uid()}`, 1e5);
683
+ const sec = second.find((l) => l.stream === s);
684
+ expect4(sec).toBeDefined();
685
+ expect4(sec.retry).toBe(1);
686
+ } finally {
687
+ await fresh.dispose();
688
+ }
689
+ });
690
+ it4("reports lagging=true from the lagging frontier and false from the leading frontier", async () => {
691
+ const fresh = await options.factory();
692
+ try {
693
+ await fresh.drop();
694
+ await fresh.seed();
695
+ const s = `lease-lag-${uid()}`;
696
+ await fresh.subscribe([{ stream: s }]);
697
+ await fresh.commit(
698
+ s,
699
+ [inc(1)],
700
+ make_meta({ stream: s })
701
+ );
702
+ const lag = await fresh.claim(1, 0, `w-${uid()}`, 0);
703
+ expect4(lag.find((l) => l.stream === s)?.lagging).toBe(true);
704
+ const lead = await fresh.claim(0, 1, `w-${uid()}`, 1e5);
705
+ expect4(lead.find((l) => l.stream === s)?.lagging).toBe(false);
706
+ } finally {
707
+ await fresh.dispose();
708
+ }
709
+ });
710
+ });
665
711
  describe4("block", () => {
666
712
  it4("hides blocked streams from claim", async () => {
667
713
  const s = `block-${uid()}`;