From 4ca4e709c5478b60139c9b145b618989298ac1cb Mon Sep 17 00:00:00 2001 From: Dominic Griesel Date: Tue, 29 Oct 2024 13:38:32 +0100 Subject: [PATCH 1/2] revert: replace `wait` with `setTimeout` from `node:timers/promises` This reverts commit cd90c096da8e4ce03649f262145b7dd2245c5858. --- 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 | 5 +- .../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, 82 insertions(+), 175 deletions(-) delete mode 100644 packages/maintenance/src/refactorWait.ts diff --git a/packages/cc/src/cc/Security2CC.ts b/packages/cc/src/cc/Security2CC.ts index 292a8a6a4cff..b7f2b1a176b6 100644 --- a/packages/cc/src/cc/Security2CC.ts +++ b/packages/cc/src/cc/Security2CC.ts @@ -44,8 +44,8 @@ import type { } from "@zwave-js/host/safe"; import { Bytes } from "@zwave-js/shared/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 49a604eeec21..1da38047f43f 100644 --- a/packages/cc/src/cc/SecurityCC.ts +++ b/packages/cc/src/cc/SecurityCC.ts @@ -29,8 +29,8 @@ import type { } from "@zwave-js/host/safe"; import { Bytes } from "@zwave-js/shared/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 20259d1b5903..d04bef72770c 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 51caecbd7e7a..f6ea26639c95 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 deleted file mode 100644 index dcf2e79aa719..000000000000 --- a/packages/maintenance/src/refactorWait.ts +++ /dev/null @@ -1,88 +0,0 @@ -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 1956062822e0..698897b0cd55 100644 --- a/packages/serial/src/serialport/ZWaveSerialPort.test.ts +++ b/packages/serial/src/serialport/ZWaveSerialPort.test.ts @@ -1,7 +1,7 @@ import { Bytes } from "@zwave-js/shared/safe"; +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 1ee5a2fbd97f..d153f9e6398a 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 f2df234a56c4..8dd06ad604ca 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 7d371d2149d5..78db7005be82 100644 --- a/packages/zwave-js/src/lib/controller/Controller.ts +++ b/packages/zwave-js/src/lib/controller/Controller.ts @@ -372,6 +372,7 @@ import { pick, } from "@zwave-js/shared"; import { distinct } from "alcalzone-shared/arrays"; +import { wait } from "alcalzone-shared/async"; import { type DeferredPromise, createDeferredPromise, @@ -379,7 +380,6 @@ 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"; @@ -3224,7 +3224,7 @@ export class ZWaveController for (const task of tasks) { const result = await Promise.race([ - wait(S0_TIMEOUT, false as const, { ref: false }), + wait(S0_TIMEOUT, true).then(() => false as const), task().catch(() => false as const), ]); if (result === false) { @@ -3503,7 +3503,7 @@ export class ZWaveController // TODO: Validate client-side auth if requested const grantResult = await Promise.race([ - wait(inclusionTimeouts.TAI1, false as const, { ref: false }), + wait(inclusionTimeouts.TAI1, true).then(() => false as const), userCallbacks .grantSecurityClasses({ securityClasses: supportedKeys, @@ -3600,7 +3600,7 @@ export class ZWaveController pinResult = inclusionOptions.dsk.slice(0, 5); } else { pinResult = await Promise.race([ - wait(tai2RemainingMs, false as const, { ref: false }), + wait(tai2RemainingMs, true).then(() => false as const), 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 7901e6e66c28..77035fd31e56 100644 --- a/packages/zwave-js/src/lib/driver/Driver.ts +++ b/packages/zwave-js/src/lib/driver/Driver.ts @@ -182,6 +182,7 @@ import { pick, } from "@zwave-js/shared"; import { distinct } from "alcalzone-shared/arrays"; +import { wait } from "alcalzone-shared/async"; import { type DeferredPromise, createDeferredPromise, @@ -192,7 +193,6 @@ 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"; @@ -2749,7 +2749,7 @@ export class Driver extends TypedEventEmitter `Firmware updated. No restart or re-interview required. Refreshing version information in ${waitTime} seconds...`, ); - await wait(waitTime * 1000, undefined, { ref: false }); + await wait(waitTime * 1000, true); try { const versionAPI = node.commandClasses.Version; @@ -5678,8 +5678,7 @@ ${handlers.length} left`, ); await wait( this.options.timeouts.retryJammed, - undefined, - { ref: false }, + true, ); continue attemptMessage; @@ -7287,7 +7286,7 @@ ${handlers.length} left`, this._enterBootloaderPromise = createDeferredPromise(); const success = await Promise.race([ this._enterBootloaderPromise.then(() => true), - wait(5000, false, { ref: false }), + wait(5000, true).then(() => 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 4b2e87d86962..c563a70381c9 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, undefined, { ref: false }); + await wait(segmentDelay, true); } const segment = unsentSegments.shift()!; @@ -409,7 +409,7 @@ export const maybeTransportServiceGenerator: MessageGeneratorImplementation< level: "debug", }); - await wait(waitTime, undefined, { ref: false }); + await wait(waitTime, true); 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 a8a4b367e48c..a0fd0920a78e 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 0932ca2b0644..78e0b864bb19 100644 --- a/packages/zwave-js/src/lib/node/Node.ts +++ b/packages/zwave-js/src/lib/node/Node.ts @@ -225,6 +225,7 @@ import { pick, stringify, } from "@zwave-js/shared"; +import { wait } from "alcalzone-shared/async"; import { type DeferredPromise, createDeferredPromise, @@ -234,8 +235,6 @@ 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 { isUint8Array } from "node:util/types"; import semver from "semver"; import { RemoveNodeReason } from "../controller/Inclusion"; import { determineNIF } from "../controller/NodeInformationFrame"; @@ -5916,7 +5915,7 @@ ${formatRouteHealthCheckSummary(this.id, otherNode.id, summary)}`, options.interval - (Date.now() - lastStart), ); await Promise.race([ - wait(waitDurationMs, undefined, { ref: false }), + wait(waitDurationMs, true), 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 0c802e634042..059d8c9964e4 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 { Bytes, 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 778e3ab6b683..bfbeb28a2028 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,10 +465,7 @@ 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, undefined, { - ref: false, - }); + yield () => wait(conservativeWaitTime * 1000, true); } } 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 cc423232f9ee..5acfc308b636 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 e0b97c364f16..b99c1977ba42 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 6a6d72ff5fb4..17e70365ae34 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 { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; 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 b3820be004fb..736216c9a9c3 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 8098c3a97114..ddc52c574833 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 6ebf5edf6909..e1ed5ddb699f 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 a0fbbcfd6a44..0cc050765dc9 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 09d8b911d44d..e0b90d97733b 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 { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; 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 9935bacc7e48..f124ca57ec5e 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 017d5b273f94..3497bc264da4 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 8ef422fbd58e..3c9732f9c809 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 5af44a799a40..58a43e3cd384 100644 --- a/packages/zwave-js/src/lib/test/driver/bootloaderDetection.test.ts +++ b/packages/zwave-js/src/lib/test/driver/bootloaderDetection.test.ts @@ -1,6 +1,6 @@ import { Bytes } from "@zwave-js/shared"; import { type MockControllerBehavior } from "@zwave-js/testing"; -import { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; 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 3be8cb46a189..5a7023b04c3f 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 { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; 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 295a7379bc32..42219793a1f7 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 b90e82eaac4f..929f77bdfdbc 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 { Bytes, 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 e6adad6cec55..aaab6a3edd2e 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 { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; 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 9469a9e9a11c..bef61f32dec9 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 { Bytes, 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 ae4dc090f990..abfd5aa06510 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 { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; 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 4557337de20b..eee056f29c39 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 { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; 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 98430e952e2e..3cb19c10bc05 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 f83d00a1b511..994574552cbe 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, "timeout"), + wait(5000).then(() => "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, "timeout"), + wait(5000).then(() => "timeout"), queryBasicPromise2.catch(() => "error"), ]); @@ -283,7 +283,7 @@ integrationTest( driver.driverLog.sendQueue(driver["queue"]); let result = await Promise.race([ - wait(500, "timeout"), + wait(500).then(() => "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, "timeout"), + wait(500).then(() => "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 962637a19fed..d92785fac513 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, "timeout"), + wait(MOCK_FRAME_ACK_TIMEOUT + 100).then(() => "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 5e4d02cef813..2dae0ededf10 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, "timeout"), + wait(2000).then(() => "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 9da52a6ef1fb..a5d07c6e0b85 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 9768d4e1d9cd..a76f267286c0 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 5e4d4582483a..1c6cfb43015a 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 { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; 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, undefined, { ref: false }); + const wait10s = wait(10000, true); 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 7175b103c9bf..cb16692ce7e3 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 { Bytes, 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 6f827abed200..f255ee318a9d 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 62750a33f635..4d18d128968c 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 { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; 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 82e2c1e7fa72..623664cb10a3 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 18650a7ee3f4..9a699766c21c 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 3fcd44426203..3e2e91de6aa1 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 { Bytes, 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 10d18d369189..53e9d33900c7 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 { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; 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 0b4637087c7c..a54177c9a97d 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 { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; 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 70744efcd9f2..07d31ad25340 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 { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; 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 c4fc6aca1b0d..e956097502aa 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 { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; 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 9bc73c5b5190..216ec6dadf6f 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 { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; 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 d178aac031f2..b33e29ec0735 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 { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; 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 51150ee8d278..ff0c5d8d4e75 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 { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; 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 059e70a3f4a7..37646ee63fec 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 { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; 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 9d0e1936357b..a5b315070b79 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 { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; 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 8f95779e9a5a..4c5f4d61f7fe 100644 --- a/packages/zwave-js/src/lib/test/driver/successfulPingChangeNodeStatus.test.ts +++ b/packages/zwave-js/src/lib/test/driver/successfulPingChangeNodeStatus.test.ts @@ -6,8 +6,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 b49e20b702f6..a8d0b7d34dae 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 { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; 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 401c25089bad..a3b3009c460a 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 { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; 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 ffb9ed4cde04..9f738899a40b 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 6240af244fc3..f71fa4683738 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 16719240638d..8672acff5072 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 a7cf932742b2..623f835c33e3 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 { setTimeout as wait } from "node:timers/promises"; +import { wait } from "alcalzone-shared/async"; import { integrationTest } from "../integrationTestSuite"; integrationTest( diff --git a/test/run.ts b/test/run.ts index 2700a41658d3..185bda23d839 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 b2a6cefc7a39..b788fdbb165f 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 76b1b2d274e9..df0ad4a5aba6 100644 --- a/test/run_zniffer.ts +++ b/test/run_zniffer.ts @@ -1,4 +1,4 @@ -import { setTimeout as _wait } from "node:timers/promises"; +import { wait as _wait } from "alcalzone-shared/async"; import "reflect-metadata"; import { Zniffer } from "zwave-js"; From d9a27b6cc82989b8e5adabca48edec69574ce2be Mon Sep 17 00:00:00 2001 From: Dominic Griesel Date: Tue, 29 Oct 2024 13:46:17 +0100 Subject: [PATCH 2/2] fix: lost import during merge --- packages/zwave-js/src/lib/node/Node.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/zwave-js/src/lib/node/Node.ts b/packages/zwave-js/src/lib/node/Node.ts index 78e0b864bb19..0280acae3a2d 100644 --- a/packages/zwave-js/src/lib/node/Node.ts +++ b/packages/zwave-js/src/lib/node/Node.ts @@ -221,6 +221,7 @@ import { formatId, getEnumMemberName, getErrorMessage, + isUint8Array, noop, pick, stringify,