]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
refactor: move constants to domain-appropriate locations
authorJérôme Benoit <jerome.benoit@sap.com>
Tue, 31 Mar 2026 23:15:35 +0000 (01:15 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Tue, 31 Mar 2026 23:15:35 +0000 (01:15 +0200)
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.

16 files changed:
src/charging-station/ChargingStation.ts
src/charging-station/ocpp/1.6/OCPP16Constants.ts
src/charging-station/ocpp/1.6/OCPP16RequestService.ts
src/charging-station/ocpp/2.0/OCPP20Constants.ts
src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts
src/charging-station/ocpp/2.0/OCPP20VariableManager.ts
src/charging-station/ocpp/2.0/OCPP20VariableRegistry.ts
src/charging-station/ocpp/OCPPConstants.ts
src/charging-station/ocpp/index.ts
src/charging-station/ui-server/AbstractUIServer.ts
src/exception/OCPPError.ts
src/utils/Constants.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts
tests/charging-station/ocpp/2.0/OCPP20TestUtils.ts
tests/charging-station/ocpp/2.0/OCPP20VariableManager.test.ts
tests/exception/OCPPError.test.ts

index 87ebc66c450df1e21bb86e2872dd9cc0ea33e640..30e46f4cdd245afb0824364b689c551144524286 100644 (file)
@@ -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,
index f430706a5f434e47cc31a4d0b114eaaaa1a139ca..bd70fb8d0723d39c9f59c01cb2a1ceb1f58e6bbe 100644 (file)
@@ -288,4 +288,6 @@ export class OCPP16Constants extends OCPPConstants {
       },
       // { from: OCPP16ChargePointStatus.Faulted, to: OCPP16ChargePointStatus.Faulted }
     ])
+
+  static readonly DEFAULT_IDTAG = '00000000'
 }
index 255bbc7cf585538ef1e56d9a223b2af4b096e47b..5b850139253ce95db212d099860929e4ec7f007e 100644 (file)
@@ -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
index c91d047a3bdd78e350d2e8a2e9a4050687662e8b..e94f61ce762648cbec2a8c980bf589c45c807bad 100644 (file)
@@ -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.
index 58056fa7e2b4c277cb620ab492098efbdbc05e58..90df5d0c164d4025a4af7a40343869061527d3e3 100644 (file)
@@ -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()
index 0e164f790f094a733a395215ea7bcf2ec4ae575e..2a00f67267caab7be404d84c557b1df74a6abfc8 100644 (file)
@@ -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(
index dfc71424110025008f315913d782634f0e28666e..2937c8d16dc9ce7e6c0e073cdfade4172675d31a 100644 (file)
@@ -719,9 +719,9 @@ export const VARIABLE_REGISTRY: Record<string, VariableMetadata> = {
   )]: {
     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<string, VariableMetadata> = {
   )]: {
     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<string, VariableMetadata> = {
   [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,
index 71914164df305f83caadd030b7e78ee271ccf439..0583649b2002f82124b278a9213b4243291c282f 100644 (file)
@@ -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
   }
index 8e3bc7aabcbace929d0769ffee44dd854c63ddd6..56a33059dfd603f821257758d9b76e1aff1741c7 100644 (file)
@@ -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'
index 8654901be35891a81300e92407d1b1c3cc0022ec..04d4d5abc477c38596af02ec60d724f216061180 100644 (file)
@@ -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<ProtocolResponse> {
index a64e2c235207b1ab0666fc11eaf7f20c58f68ae0..a72ea69f10649fa4ab4a120a85da2206a167785b 100644 (file)
@@ -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
   }
 }
index f8cffbcb96b8754f89f4cbf7f0dd07b0d4c39dfc..ed6e9a4953dbddfbf1f25d3a7f2737d25e986e4f 100644 (file)
@@ -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
-  }
 }
index b04adb71f5d27014b61ca0fd9fcf42b503d3a600..c163af83bc642ce26e7cac4eb3d3cea195c2ce5f 100644 (file)
@@ -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
index d4ab72896a64758b8693f99c78cefb2703cc29a1..1752fc4a47dbeb1cd83d3467d923fed96041d8e1 100644 (file)
@@ -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()
   )
 }
 
index 5a5ea13a1efcc42fb70589eb12077e6b1bf83419..e1e8b2a4f4e1c2221d4c5461ffb63e72ef6f6a4f 100644 (file)
@@ -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, [
index a3b8cdadeb3aac24adfa97d2f1d6c86b688f5fda..2d336ec9dd8567a3fc1f5635b7e964bd33f52d34 100644 (file)
@@ -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, '')