28
28
29
29
30
30
class Runner (TestRunner ):
31
- def __init__ (self , repl_storage_path : str , commission_on_network_dut : bool ):
31
+ def __init__ (self , repl_storage_path : str , node_id_to_commission : int = None ):
32
32
self ._repl_runner = None
33
33
self ._chip_stack = None
34
34
self ._certificate_authority_manager = None
35
35
self ._repl_storage_path = repl_storage_path
36
- self ._commission_on_network_dut = commission_on_network_dut
36
+ self ._node_id_to_commission = node_id_to_commission
37
37
38
38
async def start (self ):
39
39
chip .native .Init ()
@@ -43,13 +43,8 @@ async def start(self):
43
43
chip_stack , chip_stack .GetStorageManager ())
44
44
certificate_authority_manager .LoadAuthoritiesFromStorage ()
45
45
46
- commission_device = False
47
46
if len (certificate_authority_manager .activeCaList ) == 0 :
48
- if self ._commission_on_network_dut is False :
49
- raise Exception (
50
- 'Provided repl storage does not contain certificate. Without commission_on_network_dut, there is no reachable DUT' )
51
47
certificate_authority_manager .NewCertificateAuthority ()
52
- commission_device = True
53
48
54
49
if len (certificate_authority_manager .activeCaList [0 ].adminList ) == 0 :
55
50
certificate_authority_manager .activeCaList [0 ].NewFabricAdmin (
@@ -58,9 +53,13 @@ async def start(self):
58
53
ca_list = certificate_authority_manager .activeCaList
59
54
60
55
dev_ctrl = ca_list [0 ].adminList [0 ].NewController ()
61
- if commission_device :
62
- # These magic values are the defaults expected for YAML tests
63
- dev_ctrl .CommissionWithCode ('MT:-24J0AFN00KA0648G00' , 0x12344321 )
56
+
57
+ # Unfortunately there is no convenient way to confirm if the provided node_id has
58
+ # already been commissioned. At this point we blindly trust that we should commission
59
+ # device with the provided node id.
60
+ if self ._node_id_to_commission is not None :
61
+ # Magic value is the defaults expected for YAML tests.
62
+ dev_ctrl .CommissionWithCode ('MT:-24J0AFN00KA0648G00' , self ._node_id_to_commission )
64
63
65
64
self ._chip_stack = chip_stack
66
65
self ._certificate_authority_manager = certificate_authority_manager
0 commit comments