From ddf999b7cf9d8c121dc42527947d25f15b2a3b99 Mon Sep 17 00:00:00 2001 From: Dominic Griesel Date: Mon, 28 Oct 2024 09:16:35 +0100 Subject: [PATCH] refactor: replace `wait` function with `setTimeout` from `node:timers/promises` --- packages/cc/src/cc/Security2CC.ts | 2 +- packages/cc/src/cc/SecurityCC.ts | 2 +- .../config/maintenance/lintConfigFiles.ts | 2 +- packages/flash/src/cli.ts | 2 +- packages/maintenance/src/refactorWait.ts | 88 +++++++++++++++++++ .../src/serialport/ZWaveSerialPort.test.ts | 2 +- packages/shared/src/AsyncQueue.test.ts | 2 +- packages/testing/src/MockController.ts | 2 +- .../zwave-js/src/lib/controller/Controller.ts | 8 +- packages/zwave-js/src/lib/driver/Driver.ts | 9 +- .../src/lib/driver/MessageGenerators.ts | 6 +- packages/zwave-js/src/lib/driver/Task.test.ts | 2 +- packages/zwave-js/src/lib/node/Node.ts | 4 +- .../src/lib/node/VirtualEndpoint.test.ts | 2 +- .../src/lib/node/mixins/70_FirmwareUpdate.ts | 7 +- .../discardUnsupportedReports.test.ts | 2 +- .../mapNotificationDoorLock.test.ts | 2 +- .../cc-specific/notificationEnums.test.ts | 2 +- .../notificationIdleManually.test.ts | 2 +- .../notificationIdleRelated.test.ts | 2 +- .../cc-specific/undefinedTargetValue.test.ts | 2 +- .../cc-specific/unknownNotifications.test.ts | 2 +- .../compat/notificationAlarmMapping.test.ts | 2 +- .../test/compat/reInterviewWakeUpNIF.test.ts | 2 +- .../test/compliance/decodeLowerS2Keys.test.ts | 2 +- .../discardInsecureCommands.test.ts | 2 +- .../test/driver/bootloaderDetection.test.ts | 2 +- .../lib/test/driver/controllerJammed.test.ts | 2 +- .../createCCValuesUsingKnownVersion.test.ts | 2 +- .../lib/test/driver/handleUnsolicited.test.ts | 2 +- ...noreCCVersion0ForKnownSupportedCCs.test.ts | 2 +- .../lib/test/driver/invalidPayloadLog.test.ts | 2 +- .../multiStageResponseNoTimeout.test.ts | 2 +- .../multicastOptimisticValueUpdate.test.ts | 2 +- .../driver/nodeAsleepBlockNonceReport.test.ts | 2 +- .../driver/nodeAsleepMessageOrder.test.ts | 10 +-- .../test/driver/nodeAsleepNoReject.test.ts | 4 +- .../driver/nodeAsleepPingResolves.test.ts | 4 +- .../lib/test/driver/nodeDeadReject.test.ts | 2 +- .../driver/nodeUpdateBeforeCallback.test.ts | 2 +- .../driver/reInterviewAssumeAwake.test.ts | 4 +- ...iveApplicationCommandHandlerBridge.test.ts | 2 +- .../test/driver/s0AndS2Encapsulation.test.ts | 2 +- .../driver/s0EncapsulationTwoNodes.test.ts | 2 +- .../src/lib/test/driver/s2Collisions.test.ts | 2 +- .../test/driver/sendCommandProgress.test.ts | 2 +- .../lib/test/driver/sendDataFailThrow.test.ts | 2 +- .../sendDataMissingCallbackAbort.test.ts | 2 +- .../driver/sendDataMissingResponse.test.ts | 2 +- .../setValueFailedSupervisionGet.test.ts | 2 +- .../test/driver/setValueNoSupervision.test.ts | 2 +- .../setValueSucceedAfterFailure.test.ts | 2 +- ...setValueSuccessfulSupervisionNoGet.test.ts | 2 +- .../driver/setValueSupervision255Get.test.ts | 2 +- ...ValueSupervisionSuccessMoreUpdates.test.ts | 2 +- .../driver/setValueSupervisionWorking.test.ts | 2 +- .../successfulPingChangeNodeStatus.test.ts | 2 +- .../src/lib/test/driver/unknownValues.test.ts | 2 +- .../lib/test/driver/unresponsiveStick.test.ts | 2 +- .../src/lib/test/integrationTestSuite.ts | 2 +- .../src/lib/test/integrationTestSuiteMulti.ts | 2 +- .../lib/test/node/Node.waitForWakeup.test.ts | 2 +- .../legacyRefreshActuatorSensorCCs.test.ts | 2 +- test/run.ts | 2 +- test/run_duplex.ts | 2 +- test/run_zniffer.ts | 2 +- 66 files changed, 174 insertions(+), 82 deletions(-) create mode 100644 packages/maintenance/src/refactorWait.ts diff --git a/packages/cc/src/cc/Security2CC.ts b/packages/cc/src/cc/Security2CC.ts index 8328e277b7e0..996fad24b8db 100644 --- a/packages/cc/src/cc/Security2CC.ts +++ b/packages/cc/src/cc/Security2CC.ts @@ -43,8 +43,8 @@ import type { GetValueDB, } from "@zwave-js/host/safe"; import { buffer2hex, getEnumMemberName, pick } from "@zwave-js/shared/safe"; -import { wait } from "alcalzone-shared/async"; import { isArray } from "alcalzone-shared/typeguards"; +import { setTimeout as wait } from "node:timers/promises"; import { CCAPI } from "../lib/API"; import { type CCRaw, diff --git a/packages/cc/src/cc/SecurityCC.ts b/packages/cc/src/cc/SecurityCC.ts index 22063a81c72c..762f8ceef0aa 100644 --- a/packages/cc/src/cc/SecurityCC.ts +++ b/packages/cc/src/cc/SecurityCC.ts @@ -28,8 +28,8 @@ import type { GetValueDB, } from "@zwave-js/host/safe"; import { buffer2hex, num2hex, pick } from "@zwave-js/shared/safe"; -import { wait } from "alcalzone-shared/async"; import { randomBytes } from "node:crypto"; +import { setTimeout as wait } from "node:timers/promises"; import { CCAPI, PhysicalCCAPI } from "../lib/API"; import { type CCRaw, diff --git a/packages/config/maintenance/lintConfigFiles.ts b/packages/config/maintenance/lintConfigFiles.ts index d04bef72770c..20259d1b5903 100644 --- a/packages/config/maintenance/lintConfigFiles.ts +++ b/packages/config/maintenance/lintConfigFiles.ts @@ -12,12 +12,12 @@ import { num2hex, } from "@zwave-js/shared"; import { distinct } from "alcalzone-shared/arrays"; -import { wait } from "alcalzone-shared/async"; import { isArray, isObject } from "alcalzone-shared/typeguards"; import { green, red, white } from "ansi-colors"; import levenshtein from "js-levenshtein"; import type { RulesLogic } from "json-logic-js"; import * as path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import type { ConditionalParamInfoMap, ParamInfoMap } from "../src"; import { ConfigManager } from "../src/ConfigManager"; import { parseLogic } from "../src/Logic"; diff --git a/packages/flash/src/cli.ts b/packages/flash/src/cli.ts index 4a4fa5ed493d..83b81a21f174 100644 --- a/packages/flash/src/cli.ts +++ b/packages/flash/src/cli.ts @@ -1,7 +1,7 @@ import { ZWaveErrorCodes, isZWaveError } from "@zwave-js/core/safe"; -import { wait } from "alcalzone-shared/async"; import fs from "fs-extra"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import yargs from "yargs"; import { ControllerFirmwareUpdateStatus, diff --git a/packages/maintenance/src/refactorWait.ts b/packages/maintenance/src/refactorWait.ts new file mode 100644 index 000000000000..dcf2e79aa719 --- /dev/null +++ b/packages/maintenance/src/refactorWait.ts @@ -0,0 +1,88 @@ +import fs from "node:fs/promises"; +import { Project, SyntaxKind } from "ts-morph"; + +async function main() { + const project = new Project({ + tsConfigFilePath: "packages/zwave-js/tsconfig.json", + }); + + const sourceFiles = project.getSourceFiles(); + for (const file of sourceFiles) { + const waitImports = file.getImportDeclarations().filter((i) => + i.getModuleSpecifierValue() === "alcalzone-shared/async" + ).map((i) => { + const named = i.getNamedImports().find((n) => + n.getName() === "wait" + ); + if (!named) return; + return [i, named] as const; + }).filter((i) => i != undefined); + + for (const [decl, named] of waitImports) { + decl.setModuleSpecifier("node:timers/promises"); + named.replaceWithText("setTimeout as wait"); + } + + const waitCalls = file.getDescendantsOfKind(SyntaxKind.CallExpression) + .filter((c) => + c.getExpressionIfKind(SyntaxKind.Identifier)?.getText() + === "wait" + ) + .map((c) => { + const args = c.getArguments(); + if (args.length < 1 || args.length > 2) return; + const timeout = args[0]; + const unref = args[1]?.getText() as string | undefined; + const then = c.getParentIfKind( + SyntaxKind.PropertyAccessExpression, + ); + const thenCall = then?.getName() === "then" + && then.getParentIfKind(SyntaxKind.CallExpression); + const thenArg = thenCall && thenCall.getArguments()[0]; + const thenResult = thenArg + && thenArg.asKind(SyntaxKind.ArrowFunction)?.getBodyText(); + const nodeToReplace = thenResult ? thenCall : c; + + return [ + nodeToReplace, + timeout.getText(), + thenResult || "undefined", + unref, + ] as const; + }) + .filter((c) => c != undefined); + + for (const [node, timeout, thenResult, unref] of waitCalls) { + const ref = unref === "true" + ? "false" + : !!unref + ? `!${unref}` + : "true"; + if (ref === "true") { + if (thenResult === "undefined") { + node.replaceWithText(`wait(${timeout})`); + } else { + node.replaceWithText( + `wait(${timeout}, ${thenResult})`, + ); + } + } else { + node.replaceWithText( + `wait(${timeout}, ${thenResult}, { ref: ${ref} })`, + ); + } + } + + await file.save(); + } +} + +void main().catch(async (e) => { + await fs.writeFile(`${e.filePath}.old`, e.oldText); + await fs.writeFile(`${e.filePath}.new`, e.newText); + console.error(`Error refactoring file ${e.filePath} + old text: ${e.filePath}.old + new text: ${e.filePath}.new`); + + process.exit(1); +}); diff --git a/packages/serial/src/serialport/ZWaveSerialPort.test.ts b/packages/serial/src/serialport/ZWaveSerialPort.test.ts index 3376f8b466dd..f79f82fe968a 100644 --- a/packages/serial/src/serialport/ZWaveSerialPort.test.ts +++ b/packages/serial/src/serialport/ZWaveSerialPort.test.ts @@ -1,6 +1,6 @@ -import { wait } from "alcalzone-shared/async"; import ava, { type TestFn } from "ava"; import { PassThrough } from "node:stream"; +import { setTimeout as wait } from "node:timers/promises"; import sinon from "sinon"; import { MessageHeaders } from "../message/MessageHeaders"; import { createAndOpenMockedZWaveSerialPort } from "../mock/MockSerialPort"; diff --git a/packages/shared/src/AsyncQueue.test.ts b/packages/shared/src/AsyncQueue.test.ts index d153f9e6398a..1ee5a2fbd97f 100644 --- a/packages/shared/src/AsyncQueue.test.ts +++ b/packages/shared/src/AsyncQueue.test.ts @@ -1,5 +1,5 @@ -import { wait } from "alcalzone-shared/async"; import test from "ava"; +import { setTimeout as wait } from "node:timers/promises"; import { AsyncQueue } from "./AsyncQueue"; test("can be iterated over after adding items", async (t) => { diff --git a/packages/testing/src/MockController.ts b/packages/testing/src/MockController.ts index 4cb57a23b8e2..cfec0742cde7 100644 --- a/packages/testing/src/MockController.ts +++ b/packages/testing/src/MockController.ts @@ -19,8 +19,8 @@ import { import type { MockPortBinding } from "@zwave-js/serial/mock"; import { AsyncQueue } from "@zwave-js/shared"; import { TimedExpectation } from "@zwave-js/shared/safe"; -import { wait } from "alcalzone-shared/async"; import { randomInt } from "node:crypto"; +import { setTimeout as wait } from "node:timers/promises"; import { type MockControllerCapabilities, getDefaultMockControllerCapabilities, diff --git a/packages/zwave-js/src/lib/controller/Controller.ts b/packages/zwave-js/src/lib/controller/Controller.ts index 211f40671d32..d83a8634f391 100644 --- a/packages/zwave-js/src/lib/controller/Controller.ts +++ b/packages/zwave-js/src/lib/controller/Controller.ts @@ -370,7 +370,6 @@ import { pick, } from "@zwave-js/shared"; import { distinct } from "alcalzone-shared/arrays"; -import { wait } from "alcalzone-shared/async"; import { type DeferredPromise, createDeferredPromise, @@ -378,6 +377,7 @@ import { import { roundTo } from "alcalzone-shared/math"; import { isObject } from "alcalzone-shared/typeguards"; import crypto from "node:crypto"; +import { setTimeout as wait } from "node:timers/promises"; import type { Driver } from "../driver/Driver"; import { cacheKeyUtils, cacheKeys } from "../driver/NetworkCache"; import type { StatisticsEventCallbacks } from "../driver/Statistics"; @@ -3221,7 +3221,7 @@ export class ZWaveController for (const task of tasks) { const result = await Promise.race([ - wait(S0_TIMEOUT, true).then(() => false as const), + wait(S0_TIMEOUT, false as const, { ref: false }), task().catch(() => false as const), ]); if (result === false) { @@ -3500,7 +3500,7 @@ export class ZWaveController // TODO: Validate client-side auth if requested const grantResult = await Promise.race([ - wait(inclusionTimeouts.TAI1, true).then(() => false as const), + wait(inclusionTimeouts.TAI1, false as const, { ref: false }), userCallbacks .grantSecurityClasses({ securityClasses: supportedKeys, @@ -3597,7 +3597,7 @@ export class ZWaveController pinResult = inclusionOptions.dsk.slice(0, 5); } else { pinResult = await Promise.race([ - wait(tai2RemainingMs, true).then(() => false as const), + wait(tai2RemainingMs, false as const, { ref: false }), userCallbacks .validateDSKAndEnterPIN(dsk) // ignore errors in application callbacks diff --git a/packages/zwave-js/src/lib/driver/Driver.ts b/packages/zwave-js/src/lib/driver/Driver.ts index 31e66af87805..e82be5ffdc36 100644 --- a/packages/zwave-js/src/lib/driver/Driver.ts +++ b/packages/zwave-js/src/lib/driver/Driver.ts @@ -179,7 +179,6 @@ import { pick, } from "@zwave-js/shared"; import { distinct } from "alcalzone-shared/arrays"; -import { wait } from "alcalzone-shared/async"; import { type DeferredPromise, createDeferredPromise, @@ -190,6 +189,7 @@ import { randomBytes } from "node:crypto"; import type { EventEmitter } from "node:events"; import os from "node:os"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import { URL } from "node:url"; import * as util from "node:util"; import { SerialPort } from "serialport"; @@ -2746,7 +2746,7 @@ export class Driver extends TypedEventEmitter `Firmware updated. No restart or re-interview required. Refreshing version information in ${waitTime} seconds...`, ); - await wait(waitTime * 1000, true); + await wait(waitTime * 1000, undefined, { ref: false }); try { const versionAPI = node.commandClasses.Version; @@ -5676,7 +5676,8 @@ ${handlers.length} left`, ); await wait( this.options.timeouts.retryJammed, - true, + undefined, + { ref: false }, ); continue attemptMessage; @@ -7284,7 +7285,7 @@ ${handlers.length} left`, this._enterBootloaderPromise = createDeferredPromise(); const success = await Promise.race([ this._enterBootloaderPromise.then(() => true), - wait(5000, true).then(() => false), + wait(5000, false, { ref: false }), ]); if (success) { this.controllerLog.print("Entered bootloader"); diff --git a/packages/zwave-js/src/lib/driver/MessageGenerators.ts b/packages/zwave-js/src/lib/driver/MessageGenerators.ts index 8acbd488e616..867da99ea8a6 100644 --- a/packages/zwave-js/src/lib/driver/MessageGenerators.ts +++ b/packages/zwave-js/src/lib/driver/MessageGenerators.ts @@ -50,11 +50,11 @@ import { } from "@zwave-js/serial/serialapi"; import { type ContainsCC, containsCC } from "@zwave-js/serial/serialapi"; import { getErrorMessage } from "@zwave-js/shared"; -import { wait } from "alcalzone-shared/async"; import { type DeferredPromise, createDeferredPromise, } from "alcalzone-shared/deferred-promise"; +import { setTimeout as wait } from "node:timers/promises"; import type { Driver } from "./Driver"; import type { MessageGenerator } from "./Transaction"; @@ -332,7 +332,7 @@ export const maybeTransportServiceGenerator: MessageGeneratorImplementation< if (isFirstTransferredSegment) { isFirstTransferredSegment = false; } else if (segmentDelay) { - await wait(segmentDelay, true); + await wait(segmentDelay, undefined, { ref: false }); } const segment = unsentSegments.shift()!; @@ -409,7 +409,7 @@ export const maybeTransportServiceGenerator: MessageGeneratorImplementation< level: "debug", }); - await wait(waitTime, true); + await wait(waitTime, undefined, { ref: false }); continue attempts; } diff --git a/packages/zwave-js/src/lib/driver/Task.test.ts b/packages/zwave-js/src/lib/driver/Task.test.ts index a0fd0920a78e..a8a4b367e48c 100644 --- a/packages/zwave-js/src/lib/driver/Task.test.ts +++ b/packages/zwave-js/src/lib/driver/Task.test.ts @@ -1,8 +1,8 @@ import { ZWaveError, ZWaveErrorCodes, assertZWaveError } from "@zwave-js/core"; import { noop } from "@zwave-js/shared"; -import { wait } from "alcalzone-shared/async"; import { createDeferredPromise } from "alcalzone-shared/deferred-promise"; import test from "ava"; +import { setTimeout as wait } from "node:timers/promises"; import { type TaskBuilder, TaskInterruptBehavior, diff --git a/packages/zwave-js/src/lib/node/Node.ts b/packages/zwave-js/src/lib/node/Node.ts index 3ee9b3d4f241..66e7b13b4009 100644 --- a/packages/zwave-js/src/lib/node/Node.ts +++ b/packages/zwave-js/src/lib/node/Node.ts @@ -224,7 +224,6 @@ import { pick, stringify, } from "@zwave-js/shared"; -import { wait } from "alcalzone-shared/async"; import { type DeferredPromise, createDeferredPromise, @@ -234,6 +233,7 @@ import { padStart } from "alcalzone-shared/strings"; import { isArray, isObject } from "alcalzone-shared/typeguards"; import { EventEmitter } from "node:events"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import semver from "semver"; import { RemoveNodeReason } from "../controller/Inclusion"; import { determineNIF } from "../controller/NodeInformationFrame"; @@ -5914,7 +5914,7 @@ ${formatRouteHealthCheckSummary(this.id, otherNode.id, summary)}`, options.interval - (Date.now() - lastStart), ); await Promise.race([ - wait(waitDurationMs, true), + wait(waitDurationMs, undefined, { ref: false }), this._abortLinkReliabilityCheckPromise, ]); } diff --git a/packages/zwave-js/src/lib/node/VirtualEndpoint.test.ts b/packages/zwave-js/src/lib/node/VirtualEndpoint.test.ts index a10acf8f959b..51b6dcd4d116 100644 --- a/packages/zwave-js/src/lib/node/VirtualEndpoint.test.ts +++ b/packages/zwave-js/src/lib/node/VirtualEndpoint.test.ts @@ -8,8 +8,8 @@ import { import { FunctionType } from "@zwave-js/serial"; import type { MockSerialPort } from "@zwave-js/serial/mock"; import type { ThrowingMap } from "@zwave-js/shared"; -import { wait } from "alcalzone-shared/async"; import ava, { type ExecutionContext, type TestFn } from "ava"; +import { setTimeout as wait } from "node:timers/promises"; import { ZWaveController } from "../controller/Controller"; import type { Driver } from "../driver/Driver"; import { createAndStartDriver } from "../test/utils"; diff --git a/packages/zwave-js/src/lib/node/mixins/70_FirmwareUpdate.ts b/packages/zwave-js/src/lib/node/mixins/70_FirmwareUpdate.ts index 6b09c2ab80d2..e84a1cec48ec 100644 --- a/packages/zwave-js/src/lib/node/mixins/70_FirmwareUpdate.ts +++ b/packages/zwave-js/src/lib/node/mixins/70_FirmwareUpdate.ts @@ -27,13 +27,13 @@ import { import { containsCC } from "@zwave-js/serial/serialapi"; import { getEnumMemberName, throttle } from "@zwave-js/shared"; import { distinct } from "alcalzone-shared/arrays"; -import { wait } from "alcalzone-shared/async"; import { type DeferredPromise, createDeferredPromise, } from "alcalzone-shared/deferred-promise"; import { roundTo } from "alcalzone-shared/math"; import { randomBytes } from "node:crypto"; +import { setTimeout as wait } from "node:timers/promises"; import { type Task, type TaskBuilder, TaskPriority } from "../../driver/Task"; import { type Transaction } from "../../driver/Transaction"; import { SchedulePollMixin } from "./60_ScheduledPoll"; @@ -465,7 +465,10 @@ export abstract class FirmwareUpdateMixin extends SchedulePollMixin // If we've resumed the previous file, there's no need to resume the next one too shouldResume = false; - yield () => wait(conservativeWaitTime * 1000, true); + yield () => + wait(conservativeWaitTime * 1000, undefined, { + ref: false, + }); } } diff --git a/packages/zwave-js/src/lib/test/cc-specific/discardUnsupportedReports.test.ts b/packages/zwave-js/src/lib/test/cc-specific/discardUnsupportedReports.test.ts index 5acfc308b636..cc423232f9ee 100644 --- a/packages/zwave-js/src/lib/test/cc-specific/discardUnsupportedReports.test.ts +++ b/packages/zwave-js/src/lib/test/cc-specific/discardUnsupportedReports.test.ts @@ -8,8 +8,8 @@ import { RateType, } from "@zwave-js/cc"; import { createMockZWaveRequestFrame } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/packages/zwave-js/src/lib/test/cc-specific/mapNotificationDoorLock.test.ts b/packages/zwave-js/src/lib/test/cc-specific/mapNotificationDoorLock.test.ts index b99c1977ba42..e0b97c364f16 100644 --- a/packages/zwave-js/src/lib/test/cc-specific/mapNotificationDoorLock.test.ts +++ b/packages/zwave-js/src/lib/test/cc-specific/mapNotificationDoorLock.test.ts @@ -2,8 +2,8 @@ import { DoorLockMode } from "@zwave-js/cc"; import { DoorLockCCValues } from "@zwave-js/cc/DoorLockCC"; import { NotificationCCReport } from "@zwave-js/cc/NotificationCC"; import { createMockZWaveRequestFrame } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/packages/zwave-js/src/lib/test/cc-specific/notificationEnums.test.ts b/packages/zwave-js/src/lib/test/cc-specific/notificationEnums.test.ts index 3c935c56b20a..bec1f61186de 100644 --- a/packages/zwave-js/src/lib/test/cc-specific/notificationEnums.test.ts +++ b/packages/zwave-js/src/lib/test/cc-specific/notificationEnums.test.ts @@ -4,7 +4,7 @@ import { } from "@zwave-js/cc/NotificationCC"; import { CommandClasses, type ValueMetadataNumeric } from "@zwave-js/core"; import { createMockZWaveRequestFrame } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/packages/zwave-js/src/lib/test/cc-specific/notificationIdleManually.test.ts b/packages/zwave-js/src/lib/test/cc-specific/notificationIdleManually.test.ts index 736216c9a9c3..b3820be004fb 100644 --- a/packages/zwave-js/src/lib/test/cc-specific/notificationIdleManually.test.ts +++ b/packages/zwave-js/src/lib/test/cc-specific/notificationIdleManually.test.ts @@ -3,8 +3,8 @@ import { NotificationCCValues, } from "@zwave-js/cc/NotificationCC"; import { createMockZWaveRequestFrame } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest("Notification values can get idled manually", { diff --git a/packages/zwave-js/src/lib/test/cc-specific/notificationIdleRelated.test.ts b/packages/zwave-js/src/lib/test/cc-specific/notificationIdleRelated.test.ts index ddc52c574833..8098c3a97114 100644 --- a/packages/zwave-js/src/lib/test/cc-specific/notificationIdleRelated.test.ts +++ b/packages/zwave-js/src/lib/test/cc-specific/notificationIdleRelated.test.ts @@ -3,8 +3,8 @@ import { NotificationCCValues, } from "@zwave-js/cc/NotificationCC"; import { createMockZWaveRequestFrame } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/packages/zwave-js/src/lib/test/cc-specific/undefinedTargetValue.test.ts b/packages/zwave-js/src/lib/test/cc-specific/undefinedTargetValue.test.ts index e1ed5ddb699f..6ebf5edf6909 100644 --- a/packages/zwave-js/src/lib/test/cc-specific/undefinedTargetValue.test.ts +++ b/packages/zwave-js/src/lib/test/cc-specific/undefinedTargetValue.test.ts @@ -4,8 +4,8 @@ import { } from "@zwave-js/cc/BinarySwitchCC"; import { createMockZWaveRequestFrame } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/packages/zwave-js/src/lib/test/cc-specific/unknownNotifications.test.ts b/packages/zwave-js/src/lib/test/cc-specific/unknownNotifications.test.ts index 0cc050765dc9..a0fbbcfd6a44 100644 --- a/packages/zwave-js/src/lib/test/cc-specific/unknownNotifications.test.ts +++ b/packages/zwave-js/src/lib/test/cc-specific/unknownNotifications.test.ts @@ -4,8 +4,8 @@ import { } from "@zwave-js/cc/NotificationCC"; import { ValueMetadata } from "@zwave-js/core"; import { createMockZWaveRequestFrame } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/packages/zwave-js/src/lib/test/compat/notificationAlarmMapping.test.ts b/packages/zwave-js/src/lib/test/compat/notificationAlarmMapping.test.ts index e0b90d97733b..09d8b911d44d 100644 --- a/packages/zwave-js/src/lib/test/compat/notificationAlarmMapping.test.ts +++ b/packages/zwave-js/src/lib/test/compat/notificationAlarmMapping.test.ts @@ -4,7 +4,7 @@ import { } from "@zwave-js/cc/NotificationCC"; import { CommandClasses } from "@zwave-js/core"; import { createMockZWaveRequestFrame } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import sinon from "sinon"; import { integrationTest } from "../integrationTestSuite"; diff --git a/packages/zwave-js/src/lib/test/compat/reInterviewWakeUpNIF.test.ts b/packages/zwave-js/src/lib/test/compat/reInterviewWakeUpNIF.test.ts index f124ca57ec5e..9935bacc7e48 100644 --- a/packages/zwave-js/src/lib/test/compat/reInterviewWakeUpNIF.test.ts +++ b/packages/zwave-js/src/lib/test/compat/reInterviewWakeUpNIF.test.ts @@ -1,8 +1,8 @@ import { ZWaveProtocolCCNodeInformationFrame } from "@zwave-js/cc"; import { CommandClasses } from "@zwave-js/core"; import { createMockZWaveRequestFrame } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/packages/zwave-js/src/lib/test/compliance/decodeLowerS2Keys.test.ts b/packages/zwave-js/src/lib/test/compliance/decodeLowerS2Keys.test.ts index 3497bc264da4..017d5b273f94 100644 --- a/packages/zwave-js/src/lib/test/compliance/decodeLowerS2Keys.test.ts +++ b/packages/zwave-js/src/lib/test/compliance/decodeLowerS2Keys.test.ts @@ -15,9 +15,9 @@ import { MockZWaveFrameType, createMockZWaveRequestFrame, } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; import { randomBytes } from "node:crypto"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/packages/zwave-js/src/lib/test/compliance/discardInsecureCommands.test.ts b/packages/zwave-js/src/lib/test/compliance/discardInsecureCommands.test.ts index 3c9732f9c809..8ef422fbd58e 100644 --- a/packages/zwave-js/src/lib/test/compliance/discardInsecureCommands.test.ts +++ b/packages/zwave-js/src/lib/test/compliance/discardInsecureCommands.test.ts @@ -16,8 +16,8 @@ import { type MockNodeBehavior, createMockZWaveRequestFrame, } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/packages/zwave-js/src/lib/test/driver/bootloaderDetection.test.ts b/packages/zwave-js/src/lib/test/driver/bootloaderDetection.test.ts index 7ff6e51a7859..2512c8985a4d 100644 --- a/packages/zwave-js/src/lib/test/driver/bootloaderDetection.test.ts +++ b/packages/zwave-js/src/lib/test/driver/bootloaderDetection.test.ts @@ -1,5 +1,5 @@ import { type MockControllerBehavior } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/packages/zwave-js/src/lib/test/driver/controllerJammed.test.ts b/packages/zwave-js/src/lib/test/driver/controllerJammed.test.ts index 5a7023b04c3f..3be8cb46a189 100644 --- a/packages/zwave-js/src/lib/test/driver/controllerJammed.test.ts +++ b/packages/zwave-js/src/lib/test/driver/controllerJammed.test.ts @@ -15,7 +15,7 @@ import { SendDataResponse, } from "@zwave-js/serial/serialapi"; import { type MockControllerBehavior } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import sinon from "sinon"; import { MockControllerCommunicationState, diff --git a/packages/zwave-js/src/lib/test/driver/createCCValuesUsingKnownVersion.test.ts b/packages/zwave-js/src/lib/test/driver/createCCValuesUsingKnownVersion.test.ts index 42219793a1f7..295a7379bc32 100644 --- a/packages/zwave-js/src/lib/test/driver/createCCValuesUsingKnownVersion.test.ts +++ b/packages/zwave-js/src/lib/test/driver/createCCValuesUsingKnownVersion.test.ts @@ -1,8 +1,8 @@ import { BatteryCCReport, BatteryCCValues } from "@zwave-js/cc"; import { CommandClasses } from "@zwave-js/core"; import { createMockZWaveRequestFrame } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; // Repro for https://github.com/zwave-js/node-zwave-js/issues/5252 diff --git a/packages/zwave-js/src/lib/test/driver/handleUnsolicited.test.ts b/packages/zwave-js/src/lib/test/driver/handleUnsolicited.test.ts index c7b18b6452c5..8cdb370f39ee 100644 --- a/packages/zwave-js/src/lib/test/driver/handleUnsolicited.test.ts +++ b/packages/zwave-js/src/lib/test/driver/handleUnsolicited.test.ts @@ -2,8 +2,8 @@ import { BasicCCValues } from "@zwave-js/cc/BasicCC"; import { MessageHeaders } from "@zwave-js/serial"; import type { MockSerialPort } from "@zwave-js/serial/mock"; import { type ThrowingMap, createThrowingMap } from "@zwave-js/shared"; -import { wait } from "alcalzone-shared/async"; import ava, { type TestFn } from "ava"; +import { setTimeout as wait } from "node:timers/promises"; import type { Driver } from "../../driver/Driver"; import { ZWaveNode } from "../../node/Node"; import { createAndStartDriver } from "../utils"; diff --git a/packages/zwave-js/src/lib/test/driver/ignoreCCVersion0ForKnownSupportedCCs.test.ts b/packages/zwave-js/src/lib/test/driver/ignoreCCVersion0ForKnownSupportedCCs.test.ts index aaab6a3edd2e..e6adad6cec55 100644 --- a/packages/zwave-js/src/lib/test/driver/ignoreCCVersion0ForKnownSupportedCCs.test.ts +++ b/packages/zwave-js/src/lib/test/driver/ignoreCCVersion0ForKnownSupportedCCs.test.ts @@ -29,7 +29,7 @@ import { MockZWaveFrameType, createMockZWaveRequestFrame, } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; // Repro for https://github.com/zwave-js/node-zwave-js/issues/6305 diff --git a/packages/zwave-js/src/lib/test/driver/invalidPayloadLog.test.ts b/packages/zwave-js/src/lib/test/driver/invalidPayloadLog.test.ts index 313886f3c49f..0b06e19af19e 100644 --- a/packages/zwave-js/src/lib/test/driver/invalidPayloadLog.test.ts +++ b/packages/zwave-js/src/lib/test/driver/invalidPayloadLog.test.ts @@ -6,9 +6,9 @@ import { SpyTransport, assertMessage } from "@zwave-js/core/test"; import { MessageHeaders } from "@zwave-js/serial"; import type { MockSerialPort } from "@zwave-js/serial/mock"; import type { ThrowingMap } from "@zwave-js/shared"; -import { wait } from "alcalzone-shared/async"; import ava, { type TestFn } from "ava"; import MockDate from "mockdate"; +import { setTimeout as wait } from "node:timers/promises"; import type { Driver } from "../../driver/Driver"; import { DriverLogger } from "../../log/Driver"; import { ZWaveNode } from "../../node/Node"; diff --git a/packages/zwave-js/src/lib/test/driver/multiStageResponseNoTimeout.test.ts b/packages/zwave-js/src/lib/test/driver/multiStageResponseNoTimeout.test.ts index abfd5aa06510..ae4dc090f990 100644 --- a/packages/zwave-js/src/lib/test/driver/multiStageResponseNoTimeout.test.ts +++ b/packages/zwave-js/src/lib/test/driver/multiStageResponseNoTimeout.test.ts @@ -13,7 +13,7 @@ import { type MockNodeBehavior, createMockZWaveRequestFrame, } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/packages/zwave-js/src/lib/test/driver/multicastOptimisticValueUpdate.test.ts b/packages/zwave-js/src/lib/test/driver/multicastOptimisticValueUpdate.test.ts index eee056f29c39..4557337de20b 100644 --- a/packages/zwave-js/src/lib/test/driver/multicastOptimisticValueUpdate.test.ts +++ b/packages/zwave-js/src/lib/test/driver/multicastOptimisticValueUpdate.test.ts @@ -1,7 +1,7 @@ import { BinarySwitchCCSet, BinarySwitchCCValues } from "@zwave-js/cc"; import { CommandClasses, NOT_KNOWN, UNKNOWN_STATE } from "@zwave-js/core"; import { MockZWaveFrameType, ccCaps } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuiteMulti"; // Regression test for #5844 diff --git a/packages/zwave-js/src/lib/test/driver/nodeAsleepBlockNonceReport.test.ts b/packages/zwave-js/src/lib/test/driver/nodeAsleepBlockNonceReport.test.ts index 3cb19c10bc05..98430e952e2e 100644 --- a/packages/zwave-js/src/lib/test/driver/nodeAsleepBlockNonceReport.test.ts +++ b/packages/zwave-js/src/lib/test/driver/nodeAsleepBlockNonceReport.test.ts @@ -10,8 +10,8 @@ import { MockZWaveFrameType, createMockZWaveRequestFrame, } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/packages/zwave-js/src/lib/test/driver/nodeAsleepMessageOrder.test.ts b/packages/zwave-js/src/lib/test/driver/nodeAsleepMessageOrder.test.ts index 994574552cbe..f83d00a1b511 100644 --- a/packages/zwave-js/src/lib/test/driver/nodeAsleepMessageOrder.test.ts +++ b/packages/zwave-js/src/lib/test/driver/nodeAsleepMessageOrder.test.ts @@ -11,8 +11,8 @@ import { MockZWaveFrameType, createMockZWaveRequestFrame, } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuiteMulti"; // Repro from #1107 @@ -186,7 +186,7 @@ integrationTest( driver.driverLog.sendQueue(driver["queue"]); let result: any = await Promise.race([ - wait(5000).then(() => "timeout"), + wait(5000, "timeout"), queryBasicPromise1.catch(() => "error"), ]); // The first command should have been sent @@ -207,7 +207,7 @@ integrationTest( driver.driverLog.sendQueue(driver["queue"]); result = await Promise.race([ - wait(5000).then(() => "timeout"), + wait(5000, "timeout"), queryBasicPromise2.catch(() => "error"), ]); @@ -283,7 +283,7 @@ integrationTest( driver.driverLog.sendQueue(driver["queue"]); let result = await Promise.race([ - wait(500).then(() => "timeout"), + wait(500, "timeout"), commandToNode17.then(() => "ok"), ]); t.is(result, "ok"); @@ -312,7 +312,7 @@ integrationTest( // And the first command should be sent result = await Promise.race([ - wait(500).then(() => "timeout"), + wait(500, "timeout"), commandToNode10.then(() => "ok"), ]); t.is(result, "ok"); diff --git a/packages/zwave-js/src/lib/test/driver/nodeAsleepNoReject.test.ts b/packages/zwave-js/src/lib/test/driver/nodeAsleepNoReject.test.ts index d92785fac513..962637a19fed 100644 --- a/packages/zwave-js/src/lib/test/driver/nodeAsleepNoReject.test.ts +++ b/packages/zwave-js/src/lib/test/driver/nodeAsleepNoReject.test.ts @@ -2,8 +2,8 @@ import { BasicCCGet, BasicCCSet } from "@zwave-js/cc"; import { MessagePriority, NodeStatus } from "@zwave-js/core"; import { type SendDataRequest } from "@zwave-js/serial/serialapi"; import { MOCK_FRAME_ACK_TIMEOUT, MockZWaveFrameType } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; // Repro from #1078 @@ -54,7 +54,7 @@ integrationTest( t.is( await Promise.race([ basicSetPromise1, - wait(MOCK_FRAME_ACK_TIMEOUT + 100).then(() => "timeout"), + wait(MOCK_FRAME_ACK_TIMEOUT + 100, "timeout"), ]), "timeout", ); diff --git a/packages/zwave-js/src/lib/test/driver/nodeAsleepPingResolves.test.ts b/packages/zwave-js/src/lib/test/driver/nodeAsleepPingResolves.test.ts index 2dae0ededf10..5e4d02cef813 100644 --- a/packages/zwave-js/src/lib/test/driver/nodeAsleepPingResolves.test.ts +++ b/packages/zwave-js/src/lib/test/driver/nodeAsleepPingResolves.test.ts @@ -1,6 +1,6 @@ import { NodeStatus } from "@zwave-js/core"; -import { wait } from "alcalzone-shared/async"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; // Repro from #6062 @@ -20,7 +20,7 @@ integrationTest( t.is(node2.status, NodeStatus.Asleep); const pingResult = await Promise.race([ node2.ping(), - wait(2000).then(() => "timeout"), + wait(2000, "timeout"), ]); t.is(pingResult, false); }, diff --git a/packages/zwave-js/src/lib/test/driver/nodeDeadReject.test.ts b/packages/zwave-js/src/lib/test/driver/nodeDeadReject.test.ts index a5d07c6e0b85..9da52a6ef1fb 100644 --- a/packages/zwave-js/src/lib/test/driver/nodeDeadReject.test.ts +++ b/packages/zwave-js/src/lib/test/driver/nodeDeadReject.test.ts @@ -1,8 +1,8 @@ import { BasicCCGet, BasicCCSet } from "@zwave-js/cc"; import { NodeStatus, ZWaveErrorCodes, assertZWaveError } from "@zwave-js/core"; import { MockZWaveFrameType } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/packages/zwave-js/src/lib/test/driver/nodeUpdateBeforeCallback.test.ts b/packages/zwave-js/src/lib/test/driver/nodeUpdateBeforeCallback.test.ts index a76f267286c0..9768d4e1d9cd 100644 --- a/packages/zwave-js/src/lib/test/driver/nodeUpdateBeforeCallback.test.ts +++ b/packages/zwave-js/src/lib/test/driver/nodeUpdateBeforeCallback.test.ts @@ -3,8 +3,8 @@ import { type MockNodeBehavior, createMockZWaveRequestFrame, } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/packages/zwave-js/src/lib/test/driver/reInterviewAssumeAwake.test.ts b/packages/zwave-js/src/lib/test/driver/reInterviewAssumeAwake.test.ts index 1c6cfb43015a..5e4d4582483a 100644 --- a/packages/zwave-js/src/lib/test/driver/reInterviewAssumeAwake.test.ts +++ b/packages/zwave-js/src/lib/test/driver/reInterviewAssumeAwake.test.ts @@ -1,7 +1,7 @@ import { WakeUpCCWakeUpNotification } from "@zwave-js/cc"; import { CommandClasses } from "@zwave-js/core"; import { createMockZWaveRequestFrame } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest("Assume a node to be awake at the start of a re-interview", { @@ -60,7 +60,7 @@ integrationTest("Assume a node to be awake at the start of a re-interview", { const interviewCompleted = new Promise((resolve) => { node.on("interview completed", () => resolve()); }); - const wait10s = wait(10000, true); + const wait10s = wait(10000, undefined, { ref: false }); await Promise.race([interviewCompleted, wait10s]); t.pass(); diff --git a/packages/zwave-js/src/lib/test/driver/receiveApplicationCommandHandlerBridge.test.ts b/packages/zwave-js/src/lib/test/driver/receiveApplicationCommandHandlerBridge.test.ts index a500c977566a..e1f6b2379589 100644 --- a/packages/zwave-js/src/lib/test/driver/receiveApplicationCommandHandlerBridge.test.ts +++ b/packages/zwave-js/src/lib/test/driver/receiveApplicationCommandHandlerBridge.test.ts @@ -2,8 +2,8 @@ import { CommandClasses, SecurityManager } from "@zwave-js/core"; import { MessageHeaders } from "@zwave-js/serial"; import type { MockSerialPort } from "@zwave-js/serial/mock"; import type { ThrowingMap } from "@zwave-js/shared"; -import { wait } from "alcalzone-shared/async"; import ava, { type TestFn } from "ava"; +import { setTimeout as wait } from "node:timers/promises"; import type { Driver } from "../../driver/Driver"; import { ZWaveNode } from "../../node/Node"; import { createAndStartDriver } from "../utils"; diff --git a/packages/zwave-js/src/lib/test/driver/s0AndS2Encapsulation.test.ts b/packages/zwave-js/src/lib/test/driver/s0AndS2Encapsulation.test.ts index f255ee318a9d..6f827abed200 100644 --- a/packages/zwave-js/src/lib/test/driver/s0AndS2Encapsulation.test.ts +++ b/packages/zwave-js/src/lib/test/driver/s0AndS2Encapsulation.test.ts @@ -20,8 +20,8 @@ import { ZWaveErrorCodes, } from "@zwave-js/core"; import { type MockNodeBehavior, MockZWaveFrameType } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest("S0 commands are S0-encapsulated, even when S2 is supported", { diff --git a/packages/zwave-js/src/lib/test/driver/s0EncapsulationTwoNodes.test.ts b/packages/zwave-js/src/lib/test/driver/s0EncapsulationTwoNodes.test.ts index 4d18d128968c..62750a33f635 100644 --- a/packages/zwave-js/src/lib/test/driver/s0EncapsulationTwoNodes.test.ts +++ b/packages/zwave-js/src/lib/test/driver/s0EncapsulationTwoNodes.test.ts @@ -15,7 +15,7 @@ import { MockZWaveFrameType, createMockZWaveRequestFrame, } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuiteMulti"; integrationTest( diff --git a/packages/zwave-js/src/lib/test/driver/s2Collisions.test.ts b/packages/zwave-js/src/lib/test/driver/s2Collisions.test.ts index 623664cb10a3..82e2c1e7fa72 100644 --- a/packages/zwave-js/src/lib/test/driver/s2Collisions.test.ts +++ b/packages/zwave-js/src/lib/test/driver/s2Collisions.test.ts @@ -25,8 +25,8 @@ import { type MockZWaveRequestFrame, createMockZWaveRequestFrame, } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/packages/zwave-js/src/lib/test/driver/sendCommandProgress.test.ts b/packages/zwave-js/src/lib/test/driver/sendCommandProgress.test.ts index 9a699766c21c..18650a7ee3f4 100644 --- a/packages/zwave-js/src/lib/test/driver/sendCommandProgress.test.ts +++ b/packages/zwave-js/src/lib/test/driver/sendCommandProgress.test.ts @@ -3,8 +3,8 @@ import { CommandClasses, TransactionState } from "@zwave-js/core"; import sinon from "sinon"; import { getEnumMemberName } from "@zwave-js/shared"; -import { wait } from "alcalzone-shared/async"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/packages/zwave-js/src/lib/test/driver/sendDataFailThrow.test.ts b/packages/zwave-js/src/lib/test/driver/sendDataFailThrow.test.ts index f43ae4ca1503..afbe59c4f6fb 100644 --- a/packages/zwave-js/src/lib/test/driver/sendDataFailThrow.test.ts +++ b/packages/zwave-js/src/lib/test/driver/sendDataFailThrow.test.ts @@ -2,8 +2,8 @@ import { BasicCCSet } from "@zwave-js/cc"; import { MessageHeaders } from "@zwave-js/serial"; import type { MockSerialPort } from "@zwave-js/serial/mock"; import type { ThrowingMap } from "@zwave-js/shared"; -import { wait } from "alcalzone-shared/async"; import ava, { type TestFn } from "ava"; +import { setTimeout as wait } from "node:timers/promises"; import type { Driver } from "../../driver/Driver"; import { ZWaveNode } from "../../node/Node"; import { createAndStartDriver } from "../utils"; diff --git a/packages/zwave-js/src/lib/test/driver/sendDataMissingCallbackAbort.test.ts b/packages/zwave-js/src/lib/test/driver/sendDataMissingCallbackAbort.test.ts index 53e9d33900c7..10d18d369189 100644 --- a/packages/zwave-js/src/lib/test/driver/sendDataMissingCallbackAbort.test.ts +++ b/packages/zwave-js/src/lib/test/driver/sendDataMissingCallbackAbort.test.ts @@ -1,6 +1,6 @@ import { FunctionType } from "@zwave-js/serial"; import { type MockControllerBehavior } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import { MockControllerCommunicationState, MockControllerStateKeys, diff --git a/packages/zwave-js/src/lib/test/driver/sendDataMissingResponse.test.ts b/packages/zwave-js/src/lib/test/driver/sendDataMissingResponse.test.ts index a54177c9a97d..0b4637087c7c 100644 --- a/packages/zwave-js/src/lib/test/driver/sendDataMissingResponse.test.ts +++ b/packages/zwave-js/src/lib/test/driver/sendDataMissingResponse.test.ts @@ -1,6 +1,6 @@ import { FunctionType } from "@zwave-js/serial"; import { type MockControllerBehavior } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import { MockControllerCommunicationState, MockControllerStateKeys, diff --git a/packages/zwave-js/src/lib/test/driver/setValueFailedSupervisionGet.test.ts b/packages/zwave-js/src/lib/test/driver/setValueFailedSupervisionGet.test.ts index 07d31ad25340..70744efcd9f2 100644 --- a/packages/zwave-js/src/lib/test/driver/setValueFailedSupervisionGet.test.ts +++ b/packages/zwave-js/src/lib/test/driver/setValueFailedSupervisionGet.test.ts @@ -8,7 +8,7 @@ import { } from "@zwave-js/cc"; import { CommandClasses, SupervisionStatus } from "@zwave-js/core"; import { type MockNodeBehavior, MockZWaveFrameType } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/packages/zwave-js/src/lib/test/driver/setValueNoSupervision.test.ts b/packages/zwave-js/src/lib/test/driver/setValueNoSupervision.test.ts index e956097502aa..c4fc6aca1b0d 100644 --- a/packages/zwave-js/src/lib/test/driver/setValueNoSupervision.test.ts +++ b/packages/zwave-js/src/lib/test/driver/setValueNoSupervision.test.ts @@ -6,7 +6,7 @@ import { } from "@zwave-js/cc"; import { CommandClasses } from "@zwave-js/core"; import { type MockNodeBehavior, MockZWaveFrameType } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest("setValue without supervision: expect validation GET", { diff --git a/packages/zwave-js/src/lib/test/driver/setValueSucceedAfterFailure.test.ts b/packages/zwave-js/src/lib/test/driver/setValueSucceedAfterFailure.test.ts index 216ec6dadf6f..9bc73c5b5190 100644 --- a/packages/zwave-js/src/lib/test/driver/setValueSucceedAfterFailure.test.ts +++ b/packages/zwave-js/src/lib/test/driver/setValueSucceedAfterFailure.test.ts @@ -6,7 +6,7 @@ import { MOCK_FRAME_ACK_TIMEOUT, type MockNodeBehavior, } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; // Repro for https://github.com/home-assistant/core/issues/98491 diff --git a/packages/zwave-js/src/lib/test/driver/setValueSuccessfulSupervisionNoGet.test.ts b/packages/zwave-js/src/lib/test/driver/setValueSuccessfulSupervisionNoGet.test.ts index b33e29ec0735..d178aac031f2 100644 --- a/packages/zwave-js/src/lib/test/driver/setValueSuccessfulSupervisionNoGet.test.ts +++ b/packages/zwave-js/src/lib/test/driver/setValueSuccessfulSupervisionNoGet.test.ts @@ -7,7 +7,7 @@ import { } from "@zwave-js/cc"; import { CommandClasses, SupervisionStatus } from "@zwave-js/core"; import { type MockNodeBehavior, MockZWaveFrameType } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import sinon from "sinon"; import { integrationTest } from "../integrationTestSuite"; diff --git a/packages/zwave-js/src/lib/test/driver/setValueSupervision255Get.test.ts b/packages/zwave-js/src/lib/test/driver/setValueSupervision255Get.test.ts index ff0c5d8d4e75..51150ee8d278 100644 --- a/packages/zwave-js/src/lib/test/driver/setValueSupervision255Get.test.ts +++ b/packages/zwave-js/src/lib/test/driver/setValueSupervision255Get.test.ts @@ -12,7 +12,7 @@ import { MockZWaveFrameType, createMockZWaveRequestFrame, } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/packages/zwave-js/src/lib/test/driver/setValueSupervisionSuccessMoreUpdates.test.ts b/packages/zwave-js/src/lib/test/driver/setValueSupervisionSuccessMoreUpdates.test.ts index 37646ee63fec..059e70a3f4a7 100644 --- a/packages/zwave-js/src/lib/test/driver/setValueSupervisionSuccessMoreUpdates.test.ts +++ b/packages/zwave-js/src/lib/test/driver/setValueSupervisionSuccessMoreUpdates.test.ts @@ -6,7 +6,7 @@ import { } from "@zwave-js/cc"; import { CommandClasses, SupervisionStatus } from "@zwave-js/core"; import { type MockNodeBehavior } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import sinon from "sinon"; import { integrationTest } from "../integrationTestSuite"; diff --git a/packages/zwave-js/src/lib/test/driver/setValueSupervisionWorking.test.ts b/packages/zwave-js/src/lib/test/driver/setValueSupervisionWorking.test.ts index a5b315070b79..9d0e1936357b 100644 --- a/packages/zwave-js/src/lib/test/driver/setValueSupervisionWorking.test.ts +++ b/packages/zwave-js/src/lib/test/driver/setValueSupervisionWorking.test.ts @@ -14,7 +14,7 @@ import { ccCaps, createMockZWaveRequestFrame, } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/packages/zwave-js/src/lib/test/driver/successfulPingChangeNodeStatus.test.ts b/packages/zwave-js/src/lib/test/driver/successfulPingChangeNodeStatus.test.ts index 682d69de0ff5..abf3170b0979 100644 --- a/packages/zwave-js/src/lib/test/driver/successfulPingChangeNodeStatus.test.ts +++ b/packages/zwave-js/src/lib/test/driver/successfulPingChangeNodeStatus.test.ts @@ -5,8 +5,8 @@ import { createThrowingMap, getEnumMemberName, } from "@zwave-js/shared"; -import { wait } from "alcalzone-shared/async"; import ava, { type TestFn } from "ava"; +import { setTimeout as wait } from "node:timers/promises"; import type { Driver } from "../../driver/Driver"; import { ZWaveNode } from "../../node/Node"; import { NodeStatus } from "../../node/_Types"; diff --git a/packages/zwave-js/src/lib/test/driver/unknownValues.test.ts b/packages/zwave-js/src/lib/test/driver/unknownValues.test.ts index a8d0b7d34dae..b49e20b702f6 100644 --- a/packages/zwave-js/src/lib/test/driver/unknownValues.test.ts +++ b/packages/zwave-js/src/lib/test/driver/unknownValues.test.ts @@ -18,7 +18,7 @@ import { ccCaps, createMockZWaveRequestFrame, } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest(`Basic Reports with the UNKNOWN state are correctly handled`, { diff --git a/packages/zwave-js/src/lib/test/driver/unresponsiveStick.test.ts b/packages/zwave-js/src/lib/test/driver/unresponsiveStick.test.ts index a3b3009c460a..401c25089bad 100644 --- a/packages/zwave-js/src/lib/test/driver/unresponsiveStick.test.ts +++ b/packages/zwave-js/src/lib/test/driver/unresponsiveStick.test.ts @@ -6,7 +6,7 @@ import { } from "@zwave-js/serial/serialapi"; import { SoftResetRequest } from "@zwave-js/serial/serialapi"; import { type MockControllerBehavior } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import Sinon from "sinon"; import { integrationTest } from "../integrationTestSuite"; diff --git a/packages/zwave-js/src/lib/test/integrationTestSuite.ts b/packages/zwave-js/src/lib/test/integrationTestSuite.ts index 9f738899a40b..ffb9ed4cde04 100644 --- a/packages/zwave-js/src/lib/test/integrationTestSuite.ts +++ b/packages/zwave-js/src/lib/test/integrationTestSuite.ts @@ -6,12 +6,12 @@ import { type MockNode, type MockNodeOptions, } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; import test, { type ExecutionContext } from "ava"; import fs from "fs-extra"; import crypto from "node:crypto"; import os from "node:os"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import type { Driver } from "../driver/Driver"; import type { PartialZWaveOptions } from "../driver/ZWaveOptions"; import type { ZWaveNode } from "../node/Node"; diff --git a/packages/zwave-js/src/lib/test/integrationTestSuiteMulti.ts b/packages/zwave-js/src/lib/test/integrationTestSuiteMulti.ts index f71fa4683738..6240af244fc3 100644 --- a/packages/zwave-js/src/lib/test/integrationTestSuiteMulti.ts +++ b/packages/zwave-js/src/lib/test/integrationTestSuiteMulti.ts @@ -6,12 +6,12 @@ import { type MockNode, type MockNodeOptions, } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; import test, { type ExecutionContext } from "ava"; import fs from "fs-extra"; import crypto from "node:crypto"; import os from "node:os"; import path from "node:path"; +import { setTimeout as wait } from "node:timers/promises"; import type { Driver } from "../driver/Driver"; import type { PartialZWaveOptions } from "../driver/ZWaveOptions"; import type { ZWaveNode } from "../node/Node"; diff --git a/packages/zwave-js/src/lib/test/node/Node.waitForWakeup.test.ts b/packages/zwave-js/src/lib/test/node/Node.waitForWakeup.test.ts index 8672acff5072..16719240638d 100644 --- a/packages/zwave-js/src/lib/test/node/Node.waitForWakeup.test.ts +++ b/packages/zwave-js/src/lib/test/node/Node.waitForWakeup.test.ts @@ -5,8 +5,8 @@ import { } from "@zwave-js/core"; import type { ThrowingMap } from "@zwave-js/shared"; import { MockController } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; import ava, { type TestFn } from "ava"; +import { setTimeout as wait } from "node:timers/promises"; import { createDefaultMockControllerBehaviors } from "../../../Utils"; import type { Driver } from "../../driver/Driver"; import { createAndStartTestingDriver } from "../../driver/DriverMock"; diff --git a/packages/zwave-js/src/lib/test/node/legacyRefreshActuatorSensorCCs.test.ts b/packages/zwave-js/src/lib/test/node/legacyRefreshActuatorSensorCCs.test.ts index 623f835c33e3..a7cf932742b2 100644 --- a/packages/zwave-js/src/lib/test/node/legacyRefreshActuatorSensorCCs.test.ts +++ b/packages/zwave-js/src/lib/test/node/legacyRefreshActuatorSensorCCs.test.ts @@ -6,7 +6,7 @@ import { import { CommandClasses } from "@zwave-js/core"; import { ApplicationUpdateRequestNodeInfoReceived } from "@zwave-js/serial/serialapi"; import { type MockNodeBehavior, MockZWaveFrameType } from "@zwave-js/testing"; -import { wait } from "alcalzone-shared/async"; +import { setTimeout as wait } from "node:timers/promises"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/test/run.ts b/test/run.ts index 185bda23d839..2700a41658d3 100644 --- a/test/run.ts +++ b/test/run.ts @@ -1,5 +1,5 @@ -import { wait as _wait } from "alcalzone-shared/async"; import path from "node:path"; +import { setTimeout as _wait } from "node:timers/promises"; import "reflect-metadata"; import { Driver } from "zwave-js"; diff --git a/test/run_duplex.ts b/test/run_duplex.ts index b788fdbb165f..b2a6cefc7a39 100644 --- a/test/run_duplex.ts +++ b/test/run_duplex.ts @@ -1,5 +1,5 @@ -import { wait as _wait } from "alcalzone-shared/async"; import path from "node:path"; +import { setTimeout as _wait } from "node:timers/promises"; import "reflect-metadata"; import { Driver, RFRegion } from "zwave-js"; diff --git a/test/run_zniffer.ts b/test/run_zniffer.ts index df0ad4a5aba6..76b1b2d274e9 100644 --- a/test/run_zniffer.ts +++ b/test/run_zniffer.ts @@ -1,4 +1,4 @@ -import { wait as _wait } from "alcalzone-shared/async"; +import { setTimeout as _wait } from "node:timers/promises"; import "reflect-metadata"; import { Zniffer } from "zwave-js";