From: Jérôme Benoit Date: Tue, 31 Mar 2026 23:15:35 +0000 (+0200) Subject: refactor: move constants to domain-appropriate locations X-Git-Tag: ocpp-server@v4.2.0~26 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=ff1696ba516778bb03912ce8a48ba56d911e8350;p=e-mobility-charging-stations-simulator.git refactor: move constants to domain-appropriate locations Move UNKNOWN_OCPP_COMMAND to OCPPConstants (cross-OCPP), DEFAULT_IDTAG to OCPP16Constants (OCPP 1.6 only), OCPP_VALUE_ABSOLUTE_MAX_LENGTH to OCPP20Constants renamed as MAX_VARIABLE_VALUE_LENGTH (OCPP 2.0 only). Extract magic numbers: SECURITY_EVENT_RETRY_DELAY_MS in OCPP20Constants, CLIENT_NOTIFICATION_DEBOUNCE_MS in AbstractUIServer, DEFAULT_WS_RECONNECT_TIMEOUT_OFFSET in Constants. --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 87ebc66c..30e46f4c 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -151,6 +151,7 @@ import { flushQueuedTransactionMessages, OCPP20ServiceUtils, OCPPAuthServiceFactory, + OCPPConstants, type OCPPIncomingRequestService, type OCPPRequestService, sendAndSetConnectorStatus, @@ -2233,7 +2234,7 @@ export class ChargingStation extends EventEmitter { // eslint-disable-next-line @typescript-eslint/no-base-to-string { rawMessage: typeof data === 'string' ? data : data.toString() } ), - Constants.UNKNOWN_OCPP_COMMAND + OCPPConstants.UNKNOWN_OCPP_COMMAND ) .catch((sendError: unknown) => { logger.error( @@ -2276,7 +2277,7 @@ export class ChargingStation extends EventEmitter { if (!(error instanceof OCPPError)) { logger.warn( `${this.logPrefix()} Error thrown at incoming OCPP command ${ - commandName ?? requestCommandName ?? Constants.UNKNOWN_OCPP_COMMAND + commandName ?? requestCommandName ?? OCPPConstants.UNKNOWN_OCPP_COMMAND // eslint-disable-next-line @typescript-eslint/no-base-to-string } message '${data.toString()}' handling is not an OCPPError:`, error @@ -2284,7 +2285,7 @@ export class ChargingStation extends EventEmitter { } logger.error( `${this.logPrefix()} Incoming OCPP command '${ - commandName ?? requestCommandName ?? Constants.UNKNOWN_OCPP_COMMAND + commandName ?? requestCommandName ?? OCPPConstants.UNKNOWN_OCPP_COMMAND // eslint-disable-next-line @typescript-eslint/no-base-to-string }' message '${data.toString()}'${ this.requests.has(messageId) @@ -2371,9 +2372,10 @@ export class ChargingStation extends EventEmitter { ) { ++this.wsConnectionRetryCount const reconnectDelay = this.getReconnectDelay() - const reconnectDelayWithdraw = 1000 const reconnectTimeout = - reconnectDelay - reconnectDelayWithdraw > 0 ? reconnectDelay - reconnectDelayWithdraw : 0 + reconnectDelay - Constants.DEFAULT_WS_RECONNECT_TIMEOUT_OFFSET > 0 + ? reconnectDelay - Constants.DEFAULT_WS_RECONNECT_TIMEOUT_OFFSET + : 0 logger.error( `${this.logPrefix()} WebSocket connection retry in ${roundTo( reconnectDelay, diff --git a/src/charging-station/ocpp/1.6/OCPP16Constants.ts b/src/charging-station/ocpp/1.6/OCPP16Constants.ts index f430706a..bd70fb8d 100644 --- a/src/charging-station/ocpp/1.6/OCPP16Constants.ts +++ b/src/charging-station/ocpp/1.6/OCPP16Constants.ts @@ -288,4 +288,6 @@ export class OCPP16Constants extends OCPPConstants { }, // { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Faulted } ]) + + static readonly DEFAULT_IDTAG = '00000000' } diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index 255bbc7c..5b850139 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -16,7 +16,7 @@ import { OCPPVersion, type RequestParams, } from '../../../types/index.js' -import { Constants, generateUUID, logger } from '../../../utils/index.js' +import { generateUUID, logger } from '../../../utils/index.js' import { OCPPRequestService } from '../OCPPRequestService.js' import { createPayloadValidatorMap, @@ -179,7 +179,7 @@ export class OCPP16RequestService extends OCPPRequestService { switch (commandName) { case OCPP16RequestCommand.AUTHORIZE: return { - idTag: Constants.DEFAULT_IDTAG, + idTag: OCPP16Constants.DEFAULT_IDTAG, ...commandParams, } as unknown as Request case OCPP16RequestCommand.BOOT_NOTIFICATION: @@ -192,7 +192,7 @@ export class OCPP16RequestService extends OCPPRequestService { return OCPP16Constants.OCPP_REQUEST_EMPTY as unknown as Request case OCPP16RequestCommand.START_TRANSACTION: return { - idTag: Constants.DEFAULT_IDTAG, + idTag: OCPP16Constants.DEFAULT_IDTAG, meterStart: chargingStation.getEnergyActiveImportRegisterByConnectorId( commandParams.connectorId as number, true diff --git a/src/charging-station/ocpp/2.0/OCPP20Constants.ts b/src/charging-station/ocpp/2.0/OCPP20Constants.ts index c91d047a..e94f61ce 100644 --- a/src/charging-station/ocpp/2.0/OCPP20Constants.ts +++ b/src/charging-station/ocpp/2.0/OCPP20Constants.ts @@ -141,9 +141,9 @@ export class OCPP20Constants extends OCPPConstants { static readonly DEFAULT_CONNECTION_URL = 'ws://localhost' static readonly FIRMWARE_INSTALL_DELAY_MS = 5000 + static readonly FIRMWARE_STATUS_DELAY_MS = 2000 static readonly FIRMWARE_VERIFY_DELAY_MS = 500 - /** * Default timeout in milliseconds for async OCPP 2.0 handler operations * (e.g., certificate file I/O). Prevents handlers from hanging indefinitely. @@ -152,9 +152,15 @@ export class OCPP20Constants extends OCPPConstants { static readonly LOG_UPLOAD_STEP_DELAY_MS = 1000 + static readonly MAX_SECURITY_EVENT_SEND_ATTEMPTS = 3 + + static readonly MAX_VARIABLE_VALUE_LENGTH = 2500 + static readonly RESET_DELAY_MS = 1000 static readonly RESET_IDLE_MONITOR_INTERVAL_MS = 5000 + static readonly SECURITY_EVENT_RETRY_DELAY_MS = 5000 + /** * Set of MessageTriggerEnumType values that the charging station supports * in the TriggerMessage handler. Used for validation and capability reporting. diff --git a/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts b/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts index 58056fa7..90df5d0c 100644 --- a/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts @@ -3370,7 +3370,7 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { }) .catch((error: unknown) => { const retryCount = (event.retryCount ?? 0) + 1 - if (retryCount >= 3) { + if (retryCount >= OCPP20Constants.MAX_SECURITY_EVENT_SEND_ATTEMPTS) { logger.warn( `${chargingStation.logPrefix()} ${moduleName}.sendQueuedSecurityEvents: Discarding event '${event.type}' after ${retryCount.toString()} failed attempts`, error @@ -3379,14 +3379,14 @@ export class OCPP20IncomingRequestService extends OCPPIncomingRequestService { return } logger.error( - `${chargingStation.logPrefix()} ${moduleName}.sendQueuedSecurityEvents: Failed to send queued event '${event.type}' (attempt ${retryCount.toString()}/3)`, + `${chargingStation.logPrefix()} ${moduleName}.sendQueuedSecurityEvents: Failed to send queued event '${event.type}' (attempt ${retryCount.toString()}/${OCPP20Constants.MAX_SECURITY_EVENT_SEND_ATTEMPTS.toString()})`, error ) queue.unshift({ ...event, retryCount }) stationState.isDrainingSecurityEvents = false setTimeout(() => { this.sendQueuedSecurityEvents(chargingStation) - }, 5000) + }, OCPP20Constants.SECURITY_EVENT_RETRY_DELAY_MS) }) } drainNextEvent() diff --git a/src/charging-station/ocpp/2.0/OCPP20VariableManager.ts b/src/charging-station/ocpp/2.0/OCPP20VariableManager.ts index 0e164f79..2a00f672 100644 --- a/src/charging-station/ocpp/2.0/OCPP20VariableManager.ts +++ b/src/charging-station/ocpp/2.0/OCPP20VariableManager.ts @@ -27,6 +27,7 @@ import { getConfigurationKey, setConfigurationKeyValue, } from '../../ConfigurationKeyUtils.js' +import { OCPP20Constants } from './OCPP20Constants.js' import { applyPostProcess, buildCaseInsensitiveCompositeKey, @@ -539,9 +540,9 @@ export class OCPP20VariableManager { variableValue = enforceReportingValueSize(variableValue, reportingValueSize) } - // Final absolute length enforcement (spec maxLength Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH) - if (variableValue.length > Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH) { - variableValue = variableValue.slice(0, Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH) + // Final absolute length enforcement (spec maxLength OCPP20Constants.MAX_VARIABLE_VALUE_LENGTH) + if (variableValue.length > OCPP20Constants.MAX_VARIABLE_VALUE_LENGTH) { + variableValue = variableValue.slice(0, OCPP20Constants.MAX_VARIABLE_VALUE_LENGTH) } return { attributeStatus: GetVariableStatusEnumType.Accepted, @@ -872,8 +873,8 @@ export class OCPP20VariableManager { // 1. Read ConfigurationValueSize and ValueSize if present and valid (>0). // 2. If both valid, use the smaller positive value. // 3. If only one valid, use that value. - // 4. If neither valid/positive, fallback to spec maxLength (Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH). - // 5. Enforce absolute upper cap of Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH (spec). + // 4. If neither valid/positive, fallback to spec maxLength (OCPP20Constants.MAX_VARIABLE_VALUE_LENGTH). + // 5. Enforce absolute upper cap of OCPP20Constants.MAX_VARIABLE_VALUE_LENGTH (spec). // 6. Reject with TooLargeElement when attributeValue length strictly exceeds effectiveLimit. if (resolvedAttributeType === AttributeEnumType.Actual) { const configurationValueSizeKey = buildCaseInsensitiveCompositeKey( @@ -913,10 +914,10 @@ export class OCPP20VariableManager { effectiveLimit = effectiveLimit != null ? Math.min(effectiveLimit, valLimit) : valLimit } if (effectiveLimit == null || effectiveLimit <= 0) { - effectiveLimit = Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH + effectiveLimit = OCPP20Constants.MAX_VARIABLE_VALUE_LENGTH } - if (effectiveLimit > Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH) { - effectiveLimit = Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH + if (effectiveLimit > OCPP20Constants.MAX_VARIABLE_VALUE_LENGTH) { + effectiveLimit = OCPP20Constants.MAX_VARIABLE_VALUE_LENGTH } if (attributeValue.length > effectiveLimit) { return this.rejectSet( diff --git a/src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts b/src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts index dfc71424..2937c8d1 100644 --- a/src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts +++ b/src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts @@ -719,9 +719,9 @@ export const VARIABLE_REGISTRY: Record = { )]: { component: OCPP20ComponentName.DeviceDataCtrlr, dataType: DataEnumType.integer, - defaultValue: Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH.toString(), + defaultValue: OCPP20Constants.MAX_VARIABLE_VALUE_LENGTH.toString(), description: 'Maximum size allowed for configuration values when setting.', - max: Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH, + max: OCPP20Constants.MAX_VARIABLE_VALUE_LENGTH, maxLength: 5, min: 1, mutability: MutabilityEnumType.ReadOnly, @@ -737,9 +737,9 @@ export const VARIABLE_REGISTRY: Record = { )]: { component: OCPP20ComponentName.DeviceDataCtrlr, dataType: DataEnumType.integer, - defaultValue: Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH.toString(), + defaultValue: OCPP20Constants.MAX_VARIABLE_VALUE_LENGTH.toString(), description: 'Maximum size of reported values.', - max: Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH, + max: OCPP20Constants.MAX_VARIABLE_VALUE_LENGTH, maxLength: 5, min: 1, mutability: MutabilityEnumType.ReadOnly, @@ -752,9 +752,9 @@ export const VARIABLE_REGISTRY: Record = { [buildRegistryKey(OCPP20ComponentName.DeviceDataCtrlr, OCPP20OptionalVariableName.ValueSize)]: { component: OCPP20ComponentName.DeviceDataCtrlr, dataType: DataEnumType.integer, - defaultValue: Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH.toString(), + defaultValue: OCPP20Constants.MAX_VARIABLE_VALUE_LENGTH.toString(), description: 'Maximum size for any stored or reported value.', - max: Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH, + max: OCPP20Constants.MAX_VARIABLE_VALUE_LENGTH, maxLength: 5, min: 1, mutability: MutabilityEnumType.ReadOnly, diff --git a/src/charging-station/ocpp/OCPPConstants.ts b/src/charging-station/ocpp/OCPPConstants.ts index 71914164..0583649b 100644 --- a/src/charging-station/ocpp/OCPPConstants.ts +++ b/src/charging-station/ocpp/OCPPConstants.ts @@ -5,7 +5,9 @@ import { ConfigurationStatus, DataTransferStatus, GenericStatus, + type IncomingRequestCommand, MeterValueMeasurand, + type RequestCommand, ReservationStatus, TriggerMessageStatus, UnlockStatus, @@ -159,6 +161,10 @@ export class OCPPConstants { static readonly OCPP_WEBSOCKET_TIMEOUT = 60000 // Ms + static readonly UNKNOWN_OCPP_COMMAND = 'unknown OCPP command' as + | IncomingRequestCommand + | RequestCommand + protected constructor () { // This is intentional } diff --git a/src/charging-station/ocpp/index.ts b/src/charging-station/ocpp/index.ts index 8e3bc7aa..56a33059 100644 --- a/src/charging-station/ocpp/index.ts +++ b/src/charging-station/ocpp/index.ts @@ -9,6 +9,7 @@ export { buildTransactionEvent, OCPP20ServiceUtils } from './2.0/OCPP20ServiceUt export { OCPP20VariableManager } from './2.0/OCPP20VariableManager.js' export { OCPPAuthServiceFactory } from './auth/index.js' export { isIdTagAuthorized } from './IdTagAuthorization.js' +export { OCPPConstants } from './OCPPConstants.js' export { OCPPIncomingRequestService } from './OCPPIncomingRequestService.js' export { OCPPRequestService } from './OCPPRequestService.js' export { createOCPPServices } from './OCPPServiceFactory.js' diff --git a/src/charging-station/ui-server/AbstractUIServer.ts b/src/charging-station/ui-server/AbstractUIServer.ts index 8654901b..04d4d5ab 100644 --- a/src/charging-station/ui-server/AbstractUIServer.ts +++ b/src/charging-station/ui-server/AbstractUIServer.ts @@ -31,6 +31,8 @@ import { } from './UIServerSecurity.js' import { getUsernameAndPasswordFromAuthorizationToken } from './UIServerUtils.js' +const CLIENT_NOTIFICATION_DEBOUNCE_MS = 500 + const moduleName = 'AbstractUIServer' export abstract class AbstractUIServer { @@ -142,7 +144,7 @@ export abstract class AbstractUIServer { this.clientNotificationDebounceTimer = setTimeout(() => { this.notifyClients() this.clientNotificationDebounceTimer = undefined - }, 500) + }, CLIENT_NOTIFICATION_DEBOUNCE_MS) } public async sendInternalRequest (request: ProtocolRequest): Promise { diff --git a/src/exception/OCPPError.ts b/src/exception/OCPPError.ts index a64e2c23..a72ea69f 100644 --- a/src/exception/OCPPError.ts +++ b/src/exception/OCPPError.ts @@ -2,7 +2,7 @@ import type { ErrorType, IncomingRequestCommand, JsonType, RequestCommand } from '../types/index.js' -import { Constants } from '../utils/index.js' +import { OCPPConstants } from '../charging-station/ocpp/OCPPConstants.js' import { BaseError } from './BaseError.js' export class OCPPError extends BaseError { @@ -19,7 +19,7 @@ export class OCPPError extends BaseError { super(message) this.code = code - this.command = command ?? Constants.UNKNOWN_OCPP_COMMAND + this.command = command ?? OCPPConstants.UNKNOWN_OCPP_COMMAND this.details = details } } diff --git a/src/utils/Constants.ts b/src/utils/Constants.ts index f8cffbcb..ed6e9a49 100644 --- a/src/utils/Constants.ts +++ b/src/utils/Constants.ts @@ -2,9 +2,7 @@ import { type AutomaticTransactionGeneratorConfiguration, type ChargingStationInfo, CurrentType, - type IncomingRequestCommand, OCPPVersion, - type RequestCommand, VendorParametersKey, } from '../types/index.js' @@ -36,8 +34,6 @@ export class Constants { static readonly DEFAULT_HEARTBEAT_INTERVAL = 60000 // Ms - static readonly DEFAULT_IDTAG = '00000000' - static readonly DEFAULT_LOG_STATISTICS_INTERVAL = 60 // Seconds static readonly DEFAULT_MESSAGE_BUFFER_FLUSH_INTERVAL = 60000 // Ms @@ -94,6 +90,7 @@ export class Constants { static readonly DEFAULT_WS_HANDSHAKE_TIMEOUT = 30 // Seconds static readonly DEFAULT_WS_PING_INTERVAL = 30 // Seconds static readonly DEFAULT_WS_RECONNECT_DELAY = 30 // Seconds + static readonly DEFAULT_WS_RECONNECT_TIMEOUT_OFFSET = 1000 // Ms static readonly EMPTY_FROZEN_OBJECT = Object.freeze({}) @@ -107,19 +104,9 @@ export class Constants { // Values exceeding this limit cause Node.js to reset the delay to 1ms static readonly MAX_SETINTERVAL_DELAY = 2147483647 // Ms - static readonly OCPP_VALUE_ABSOLUTE_MAX_LENGTH = 2500 - static readonly PERFORMANCE_RECORDS_TABLE = 'performance_records' static readonly STOP_CHARGING_STATIONS_TIMEOUT = 60000 // Ms static readonly STOP_MESSAGE_SEQUENCE_TIMEOUT = 30000 // Ms - - static readonly UNKNOWN_OCPP_COMMAND = 'unknown OCPP command' as - | IncomingRequestCommand - | RequestCommand - - private constructor () { - // This is intentional - } } diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts index b04adb71..c163af83 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts @@ -273,7 +273,7 @@ await describe('B07 - Get Base Report', async () => { // ReportingValueSize truncation test await it('should truncate long SequenceList/MemberList values per ReportingValueSize', () => { - // Ensure ReportingValueSize is at a small value (default is Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH). We will override configuration key if absent. + // Ensure ReportingValueSize is at a small value (default is OCPP20Constants.MAX_VARIABLE_VALUE_LENGTH). We will override configuration key if absent. const reportingSizeKey = buildConfigKey( OCPP20ComponentName.DeviceDataCtrlr, StandardParametersKey.ReportingValueSize diff --git a/tests/charging-station/ocpp/2.0/OCPP20TestUtils.ts b/tests/charging-station/ocpp/2.0/OCPP20TestUtils.ts index d4ab7289..1752fc4a 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20TestUtils.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20TestUtils.ts @@ -19,6 +19,7 @@ import type { } from '../../../../src/types/index.js' import { buildConfigKey } from '../../../../src/charging-station/index.js' +import { OCPP20Constants } from '../../../../src/charging-station/ocpp/2.0/OCPP20Constants.js' import { OCPP20RequestService } from '../../../../src/charging-station/ocpp/2.0/OCPP20RequestService.js' import { OCPP20ResponseService } from '../../../../src/charging-station/ocpp/2.0/OCPP20ResponseService.js' import { @@ -266,7 +267,7 @@ export function resetReportingValueSize (chargingStation: ChargingStation) { OCPP20ComponentName.DeviceDataCtrlr, OCPP20OptionalVariableName.ReportingValueSize ), - Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH.toString() + OCPP20Constants.MAX_VARIABLE_VALUE_LENGTH.toString() ) } @@ -282,12 +283,12 @@ export function resetValueSizeLimits (chargingStation: ChargingStation) { OCPP20ComponentName.DeviceDataCtrlr, OCPP20OptionalVariableName.ConfigurationValueSize ), - Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH.toString() + OCPP20Constants.MAX_VARIABLE_VALUE_LENGTH.toString() ) upsertConfigurationKey( chargingStation, buildConfigKey(OCPP20ComponentName.DeviceDataCtrlr, OCPP20OptionalVariableName.ValueSize), - Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH.toString() + OCPP20Constants.MAX_VARIABLE_VALUE_LENGTH.toString() ) } diff --git a/tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts b/tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts index 5a5ea13a..e1e8b2a4 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts @@ -1831,7 +1831,7 @@ await describe('B05 - OCPP20VariableManager', async () => { buildConfigKey(OCPP20ComponentName.ChargingStation, OCPP20VendorVariableName.ConnectionUrl), overLongValue ) - // Set generous ValueSize (1500) and ReportingValueSize (1400) so only absolute cap applies (since both < Constants.OCPP_VALUE_ABSOLUTE_MAX_LENGTH) + // Set generous ValueSize (1500) and ReportingValueSize (1400) so only absolute cap applies (since both < OCPP20Constants.MAX_VARIABLE_VALUE_LENGTH) setValueSize(station, 1500) setReportingValueSize(station, 1400) const getRes = manager.getVariables(station, [ diff --git a/tests/exception/OCPPError.test.ts b/tests/exception/OCPPError.test.ts index a3b8cdad..2d336ec9 100644 --- a/tests/exception/OCPPError.test.ts +++ b/tests/exception/OCPPError.test.ts @@ -5,10 +5,10 @@ import assert from 'node:assert/strict' import { afterEach, describe, it } from 'node:test' +import { OCPPConstants } from '../../src/charging-station/ocpp/OCPPConstants.js' import { BaseError } from '../../src/exception/BaseError.js' import { OCPPError } from '../../src/exception/OCPPError.js' import { ErrorType, RequestCommand } from '../../src/types/index.js' -import { Constants } from '../../src/utils/index.js' import { standardCleanup } from '../helpers/TestLifecycleHelpers.js' await describe('OCPPError', async () => { @@ -22,7 +22,7 @@ await describe('OCPPError', async () => { assert.strictEqual(ocppError.name, 'OCPPError') assert.strictEqual(ocppError.message, '') assert.strictEqual(ocppError.code, ErrorType.GENERIC_ERROR) - assert.strictEqual(ocppError.command, Constants.UNKNOWN_OCPP_COMMAND) + assert.strictEqual(ocppError.command, OCPPConstants.UNKNOWN_OCPP_COMMAND) assert.strictEqual(ocppError.details, undefined) assert.ok(typeof ocppError.stack === 'string') assert.notStrictEqual(ocppError.stack, '')