@@ -555,3 +555,42 @@ test(
555555 } ,
556556 testUtil . timeout . long ( )
557557)
558+
559+ test (
560+ 'test Matter list-typed attribute loading in memory' ,
561+ async ( ) => {
562+ let db = await dbApi . initRamDatabase ( )
563+ try {
564+ await dbApi . loadSchema ( db , env . schemaFile ( ) , env . zapVersion ( ) )
565+ let ctx = await zclLoader . loadZcl ( db , env . builtinMatterZclMetafile ( ) )
566+ let packageId = ctx . packageId
567+
568+ let zclCluster = await queryZcl . selectClusterByCode ( db , packageId , 0x001f )
569+
570+ /* Verify that the ACL attribute, defined using the list type format `array="true" type="X"` in XML,
571+ is correctly parsed and stored in the database as an array of AccessControlEntryStruct. */
572+ let attributes = await dbApi . dbAll (
573+ db ,
574+ "SELECT * FROM ATTRIBUTE WHERE CLUSTER_REF = ? AND CODE = 0x0000 AND NAME = 'ACL'" ,
575+ [ zclCluster . id ]
576+ )
577+ expect ( attributes . length ) . toBe ( 1 )
578+ let aclAttribute = attributes [ 0 ]
579+ expect ( aclAttribute . TYPE ) . toBe ( 'array' )
580+ expect ( aclAttribute . ARRAY_TYPE ) . toBe ( 'AccessControlEntryStruct' )
581+
582+ // verify that the ACL attribute data retrieved from the database is an array of AccessControlEntryStruct after mapping
583+ let aclAttributeMapped = await queryZcl . selectAttributeById (
584+ db ,
585+ aclAttribute . ATTRIBUTE_ID
586+ )
587+ expect ( aclAttributeMapped ) . not . toBe ( null )
588+ expect ( aclAttributeMapped . name ) . toBe ( 'ACL' )
589+ expect ( aclAttributeMapped . entryType ) . toBe ( 'AccessControlEntryStruct' )
590+ expect ( aclAttributeMapped . isArray ) . toBe ( 1 )
591+ } finally {
592+ await dbApi . closeDatabase ( db )
593+ }
594+ } ,
595+ testUtil . timeout . long ( )
596+ )
0 commit comments