Skip to content

Commit

Permalink
Fixing Spec check warnings: (project-chip#1244)
Browse files Browse the repository at this point in the history
- Fixing the warnings which show up when disabling a cluster that is not required based on a device type.
- Adding tests for it
- Github: ZAP#1243
  • Loading branch information
brdandu authored Jan 5, 2024
1 parent b952bcc commit 9c4b524
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src-electron/db/zap-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -860,10 +860,12 @@ WHEN
ENDPOINT_TYPE_CLUSTER.SIDE = new.SIDE
AND
ENDPOINT_TYPE_CLUSTER.ENABLED != 1
AND
DEVICE_TYPE_CLUSTER.CLUSTER_REF = new.CLUSTER_REF
AND
((DEVICE_TYPE_CLUSTER.INCLUDE_CLIENT = 1 AND LOWER(new.SIDE) = 'client')
OR (LOWER(new.SIDE) = 'client' AND DEVICE_TYPE_CLUSTER.LOCK_CLIENT=0 )
OR (DEVICE_TYPE_CLUSTER.INCLUDE_SERVER = 1 AND LOWER(new.SIDE) = 'SERVER')
OR (DEVICE_TYPE_CLUSTER.INCLUDE_SERVER = 1 AND LOWER(new.SIDE) = 'server')
OR (LOWER(new.SIDE) = 'server' AND DEVICE_TYPE_CLUSTER.LOCK_SERVER=0 ))
) > 0
BEGIN
Expand Down Expand Up @@ -959,10 +961,12 @@ WHEN
ENDPOINT_TYPE_CLUSTER.SIDE = new.SIDE
AND
ENDPOINT_TYPE_CLUSTER.ENABLED = 1
AND
DEVICE_TYPE_CLUSTER.CLUSTER_REF = new.CLUSTER_REF
AND
((DEVICE_TYPE_CLUSTER.INCLUDE_CLIENT = 1 AND LOWER(new.SIDE) = 'client')
OR (LOWER(new.SIDE) = 'client' AND DEVICE_TYPE_CLUSTER.LOCK_CLIENT=0 )
OR (DEVICE_TYPE_CLUSTER.INCLUDE_SERVER = 1 AND LOWER(new.SIDE) = 'SERVER')
OR (DEVICE_TYPE_CLUSTER.INCLUDE_SERVER = 1 AND LOWER(new.SIDE) = 'server')
OR (LOWER(new.SIDE) = 'server' AND DEVICE_TYPE_CLUSTER.LOCK_SERVER=0 ))
) > 0
BEGIN
Expand Down Expand Up @@ -1058,10 +1062,12 @@ WHEN
ENDPOINT_TYPE_CLUSTER.SIDE = new.SIDE
AND
ENDPOINT_TYPE_CLUSTER.ENABLED = 1
AND
DEVICE_TYPE_CLUSTER.CLUSTER_REF = new.CLUSTER_REF
AND
((DEVICE_TYPE_CLUSTER.INCLUDE_CLIENT = 1 AND LOWER(new.SIDE) = 'client')
OR (LOWER(new.SIDE) = 'client' AND DEVICE_TYPE_CLUSTER.LOCK_CLIENT=0 )
OR (DEVICE_TYPE_CLUSTER.INCLUDE_SERVER = 1 AND LOWER(new.SIDE) = 'SERVER')
OR (DEVICE_TYPE_CLUSTER.INCLUDE_SERVER = 1 AND LOWER(new.SIDE) = 'server')
OR (LOWER(new.SIDE) = 'server' AND DEVICE_TYPE_CLUSTER.LOCK_SERVER=0 ))
) > 0
BEGIN
Expand Down
34 changes: 34 additions & 0 deletions test/spec-check.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,40 @@ test(
let allClusters = await testQuery.getAllSessionClusters(db, sid)
let descriptorCluster = allClusters.find((c) => c.code === 0x001d) // Finding the descriptor cluster by code
let identifyCluster = allClusters.find((c) => c.code === 0x0003) // Finding the identify cluster by code
let onOffCluster = allClusters.find((c) => c.code === 0x0006) // Find the on/off cluster by code

// Negative test: Adding on/off cluster to endpoint 0 and then disabling it.
// Note that on/off cluster is not a required cluster based on the device types
// enabled on endpoint 0 so there should be no additional session warnings when
// enabling or disabling the on/off cluster.
let sessionNotificationCountBeforeOnOffEnabled = sessionNotifications.length
// Enable on off server cluster
await queryConfig.insertOrReplaceClusterState(
db,
endpoint0.endpointTypeId,
onOffCluster.id,
'SERVER',
true
)
sessionNotifications = await testQuery.getAllSessionNotifications(db, sid)
let sessionNotificationCountAfterOnOffEnabled = sessionNotifications.length
expect(sessionNotificationCountBeforeOnOffEnabled).toEqual(
sessionNotificationCountAfterOnOffEnabled
)

// Disable on off server cluster
await queryConfig.insertOrReplaceClusterState(
db,
endpoint0.endpointTypeId,
onOffCluster.id,
'SERVER',
false
)
sessionNotifications = await testQuery.getAllSessionNotifications(db, sid)
let sessionNotificationCountAfterOnOffDisabled = sessionNotifications.length
expect(sessionNotificationCountBeforeOnOffEnabled).toEqual(
sessionNotificationCountAfterOnOffDisabled
)

// Insert the descriptor cluster and check for session notice warnings again
await queryConfig.insertOrReplaceClusterState(
Expand Down

0 comments on commit 9c4b524

Please sign in to comment.