30
30
from chip .clusters .Attribute import EventReadResult , SubscriptionTransaction , TypedAttributePath
31
31
from chip .exceptions import ChipStackError
32
32
from chip .interaction_model import Status
33
- from matter_testing_support import MatterBaseTest , async_test_body , default_matter_test_main
33
+ from matter_testing_support import MatterBaseTest , async_test_body , default_matter_test_main , generate_random_nodeid
34
34
from mobly import asserts
35
35
36
36
@@ -87,8 +87,16 @@ def __init__(self, *args):
87
87
self .breadcrumb = 1
88
88
self .breadcrumb_queue = queue .Queue ()
89
89
self .subscription_breadcrumb = None
90
+ self .subscriptions = []
90
91
super ().__init__ (* args )
91
92
93
+
94
+ def teardown_class (self ):
95
+ for subscription in self .subscriptions :
96
+ subscription .Shutdown ()
97
+ if self .subscription_breadcrumb is not None :
98
+ self .subscription_breadcrumb .Shutdown ()
99
+
92
100
async def write_acl (self , acl ):
93
101
# This returns an attribute status
94
102
result = await self .default_controller .WriteAttribute (self .dut_node_id , [(0 , Clusters .AccessControl .Attributes .Acl (acl ))])
@@ -97,6 +105,9 @@ async def write_acl(self, acl):
97
105
async def steps_subscribe_breadcrumb (self , print_steps : bool ):
98
106
if print_steps :
99
107
self .print_step (3 , "TH2 subscribes to the Breadcrumb attribute" )
108
+ if isinstance (self .subscription_breadcrumb , Clusters .Attribute .SubscriptionTransaction ):
109
+ self .subscription_breadcrumb .Shutdown ()
110
+
100
111
self .subscription_breadcrumb = await self .TH2 .ReadAttribute (nodeid = self .dut_node_id , attributes = [(0 , Clusters .GeneralCommissioning .Attributes .Breadcrumb )], reportInterval = (1 , 5 ), keepSubscriptions = False , autoResubscribe = False )
101
112
breadcrumb_cb = AttributeChangeCallback (Clusters .GeneralCommissioning .Attributes .Breadcrumb , self .breadcrumb_queue )
102
113
self .subscription_breadcrumb .SetAttributeUpdateCallback (breadcrumb_cb )
@@ -136,7 +147,7 @@ async def test_TC_ACE_1_2(self):
136
147
fabric_admin = self .certificate_authority_manager .activeCaList [0 ].adminList [0 ]
137
148
138
149
TH1_nodeid = self .matter_test_config .controller_node_id
139
- TH2_nodeid = self . matter_test_config . controller_node_id + 1
150
+ TH2_nodeid = generate_random_nodeid ( excluded_nodeid = { TH1_nodeid })
140
151
141
152
self .TH2 = fabric_admin .NewController (nodeId = TH2_nodeid ,
142
153
paaTrustStorePath = str (self .matter_test_config .paa_trust_store_path ))
@@ -157,13 +168,15 @@ async def test_TC_ACE_1_2(self):
157
168
acl_queue = queue .Queue ()
158
169
acl_cb = AttributeChangeCallback (Clusters .AccessControl .Attributes .Acl , acl_queue )
159
170
subscription_acl .SetAttributeUpdateCallback (acl_cb )
171
+ self .subscriptions .append (subscription_acl )
160
172
161
173
self .print_step (5 , "TH2 subscribes to the AccessControlEntryChanged event" )
162
174
urgent = 1
163
175
subscription_ace = await self .TH2 .ReadEvent (nodeid = self .dut_node_id , events = [(0 , Clusters .AccessControl .Events .AccessControlEntryChanged , urgent )], reportInterval = (1 , 5 ), fabricFiltered = False , keepSubscriptions = True , autoResubscribe = False )
164
176
ace_queue = queue .Queue ()
165
177
ace_cb = EventChangeCallback (Clusters .AccessControl .Events .AccessControlEntryChanged , ace_queue )
166
178
subscription_ace .SetEventUpdateCallback (ace_cb )
179
+ self .subscriptions .append (subscription_ace )
167
180
168
181
self .print_step (6 , "TH1 writes ACL attribute" )
169
182
acl = Clusters .AccessControl .Structs .AccessControlEntryStruct (
0 commit comments