@irtio/testing 4.7.0 → 4.8.0

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.
@@ -8,6 +8,12 @@ import {
8
8
  } from "@irtio/schema";
9
9
  function deepEqual(a, b) {
10
10
  if (Object.is(a, b)) return true;
11
+ if (a instanceof Uint8Array || b instanceof Uint8Array) {
12
+ if (!(a instanceof Uint8Array) || !(b instanceof Uint8Array) || a.length !== b.length)
13
+ return false;
14
+ for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
15
+ return true;
16
+ }
11
17
  if (Array.isArray(a) || Array.isArray(b)) {
12
18
  if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;
13
19
  return a.every((v, i) => deepEqual(v, b[i]));
@@ -76,9 +82,13 @@ function singletonIsDefault(desc, value) {
76
82
  var DEFAULT_AUTO_PUMP_TICKS = 200;
77
83
 
78
84
  // src/scheduler.ts
85
+ import { Mulberry32 } from "@irtio/runtime";
86
+ var JITTER_SEED = 111245285;
79
87
  function clockScheduler(clock) {
88
+ const rng = new Mulberry32(JITTER_SEED);
80
89
  return {
81
90
  now: () => clock.now(),
91
+ random: () => rng.next(),
82
92
  setTimeout(fn, ms) {
83
93
  const handle = clock.setTimeout(fn, ms);
84
94
  return () => clock.clearTimeout(handle);
@@ -105,7 +115,7 @@ import {
105
115
  rpcTable
106
116
  } from "@irtio/protocol";
107
117
  import {
108
- Mulberry32,
118
+ Mulberry32 as Mulberry322,
109
119
  RoomCore,
110
120
  RoomFullError,
111
121
  createVisibilityPolicy,
@@ -378,7 +388,7 @@ var TestHarness = class {
378
388
  this.failOnHandlerError = options.failOnHandlerError ?? true;
379
389
  this.autoPump = options.autoPump ?? true;
380
390
  this.autoPumpTicks = options.autoPumpTicks ?? DEFAULT_AUTO_PUMP_TICKS;
381
- this.rng = new Mulberry32(options.seed ?? 1);
391
+ this.rng = new Mulberry322(options.seed ?? 1);
382
392
  this.scheduler = clockScheduler(this.clock);
383
393
  this.host = new HarnessHost(this.clock);
384
394
  this.host.onSend = (clientId, frame) => {
@@ -1056,8 +1066,8 @@ var TestHarness = class {
1056
1066
  /**
1057
1067
  * Advances until `pred()` holds. In **event mode** a tick is a zero-length clock step, so this
1058
1068
  * advances `stepMs` (1 ms by default) of fake time per attempt instead — otherwise a condition
1059
- * that depends on a timer, such as a dropped client's 250 ms reconnect backoff, could never
1060
- * become true no matter how large `maxTicks` was. Found when a test spent its whole budget
1069
+ * that depends on a timer, such as a dropped client's reconnect backoff (up to 250 ms), could
1070
+ * never become true no matter how large `maxTicks` was. Found when a test spent its whole budget
1061
1071
  * on `t.until: predicate still false after 1000 ticks`.
1062
1072
  */
1063
1073
  async until(pred, options = {}) {
package/dist/index.d.ts CHANGED
@@ -590,8 +590,8 @@ declare class TestHarness<S extends AnySchema> implements TestRoom<S> {
590
590
  /**
591
591
  * Advances until `pred()` holds. In **event mode** a tick is a zero-length clock step, so this
592
592
  * advances `stepMs` (1 ms by default) of fake time per attempt instead — otherwise a condition
593
- * that depends on a timer, such as a dropped client's 250 ms reconnect backoff, could never
594
- * become true no matter how large `maxTicks` was. Found when a test spent its whole budget
593
+ * that depends on a timer, such as a dropped client's reconnect backoff (up to 250 ms), could
594
+ * never become true no matter how large `maxTicks` was. Found when a test spent its whole budget
595
595
  * on `t.until: predicate still false after 1000 ticks`.
596
596
  */
597
597
  until(pred: () => boolean, options?: UntilOptions): Promise<void>;
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  toHaveRejected,
13
13
  toStayUnderBandwidth,
14
14
  toStayWithinPrediction
15
- } from "./chunk-RYJYSBL7.js";
15
+ } from "./chunk-MEBJSN5V.js";
16
16
 
17
17
  // src/relay-harness.ts
18
18
  import { joinRelay } from "@irtio/client";
@@ -28,7 +28,7 @@ interface IrtioMatchers<R = unknown> {
28
28
  toStayWithinPrediction(opts: PredictionBounds): R;
29
29
  }
30
30
  declare module 'vitest' {
31
- interface Matchers<T = any> extends IrtioMatchers<T> {
31
+ interface Matchers<R extends void | Promise<void> = void | Promise<void>, T = unknown> extends IrtioMatchers<R> {
32
32
  }
33
33
  }
34
34
 
package/dist/matchers.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  toHaveRejected,
6
6
  toStayUnderBandwidth,
7
7
  toStayWithinPrediction
8
- } from "./chunk-RYJYSBL7.js";
8
+ } from "./chunk-MEBJSN5V.js";
9
9
 
10
10
  // src/matchers.ts
11
11
  import { expect } from "vitest";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@irtio/testing",
3
- "version": "4.7.0",
3
+ "version": "4.8.0",
4
4
  "description": "irtio's blessed test API: testRoom() in-process rooms with real client semantics, plus Vitest matchers",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -12,6 +12,9 @@
12
12
  "access": "public"
13
13
  },
14
14
  "type": "module",
15
+ "engines": {
16
+ "node": ">=22"
17
+ },
15
18
  "main": "./dist/index.js",
16
19
  "types": "./dist/index.d.ts",
17
20
  "exports": {
@@ -28,12 +31,12 @@
28
31
  "dist"
29
32
  ],
30
33
  "dependencies": {
31
- "@irtio/client": "^4.7.0",
32
- "@irtio/bots": "^4.7.0",
33
- "@irtio/runtime": "^4.7.0",
34
- "@irtio/server": "^4.7.0",
35
- "@irtio/schema": "^4.7.0",
36
- "@irtio/protocol": "^4.7.0"
34
+ "@irtio/bots": "^4.8.0",
35
+ "@irtio/runtime": "^4.8.0",
36
+ "@irtio/protocol": "^4.8.0",
37
+ "@irtio/client": "^4.8.0",
38
+ "@irtio/schema": "^4.8.0",
39
+ "@irtio/server": "^4.8.0"
37
40
  },
38
41
  "peerDependencies": {
39
42
  "vitest": ">=3"