Skip to content

Commit

Permalink
Migrate to SetupParameters in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arkq committed Dec 2, 2024
1 parent bb89500 commit 59c8c6c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 33 deletions.
22 changes: 6 additions & 16 deletions src/python_testing/TC_MCORE_FS_1_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import logging
import os
import queue
import random
import secrets
import struct
import tempfile
Expand All @@ -51,7 +52,7 @@
import chip.clusters as Clusters
from chip import ChipDeviceCtrl
from chip.testing.apps import AppServerSubprocess
from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main, type_matches
from chip.testing.matter_testing import MatterBaseTest, SetupParameters, TestStep, async_test_body, default_matter_test_main, type_matches
from ecdsa.curves import NIST256p
from mobly import asserts
from TC_SC_3_6 import AttributeChangeAccumulator
Expand All @@ -69,14 +70,6 @@ def _generate_verifier(passcode: int, salt: bytes, iterations: int) -> bytes:
return w0.to_bytes(NIST256p.baselen, byteorder='big') + L.to_bytes('uncompressed')


@dataclass
class _SetupParameters:
setup_qr_code: str
manual_code: int
discriminator: int
passcode: int


class TC_MCORE_FS_1_2(MatterBaseTest):
@async_test_body
async def setup_class(self):
Expand Down Expand Up @@ -105,11 +98,8 @@ async def setup_class(self):
self.dut_fsa_stdin = open(dut_fsa_stdin_pipe, "w")

self.th_server_port = th_server_port
# These are default testing values.
self.th_server_setup_params = _SetupParameters(
setup_qr_code="MT:-24J0AFN00KA0648G00",
manual_code=34970112332,
discriminator=3840,
self.th_server_setup_params = SetupParameters(
discriminator=random.randint(0, 4095),
passcode=20202021)

# Start the TH_SERVER app.
Expand All @@ -133,12 +123,12 @@ def teardown_class(self):
self.storage.cleanup()
super().teardown_class()

def _ask_for_vendor_commissioning_ux_operation(self, setup_params: _SetupParameters):
def _ask_for_vendor_commissioning_ux_operation(self, setup_params: SetupParameters):
self.wait_for_user_input(
prompt_msg=f"Using the DUT vendor's provided interface, commission the ICD device using the following parameters:\n"
f"- discriminator: {setup_params.discriminator}\n"
f"- setupPinCode: {setup_params.passcode}\n"
f"- setupQRCode: {setup_params.setup_qr_code}\n"
f"- setupQRCode: {setup_params.qr_code}\n"
f"- setupManualCode: {setup_params.manual_code}\n"
f"If using FabricSync Admin test app, you may type:\n"
f">>> pairing onnetwork 111 {setup_params.passcode}")
Expand Down
23 changes: 6 additions & 17 deletions src/python_testing/TC_MCORE_FS_1_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@
import logging
import os
import queue
import random
import secrets
import struct
import tempfile
import time
from dataclasses import dataclass

import chip.clusters as Clusters
from chip import ChipDeviceCtrl
from chip.testing.apps import AppServerSubprocess
from chip.testing.matter_testing import MatterBaseTest, TestStep, async_test_body, default_matter_test_main, type_matches
from chip.testing.matter_testing import MatterBaseTest, SetupParameters, TestStep, async_test_body, default_matter_test_main, type_matches
from ecdsa.curves import NIST256p
from mobly import asserts
from TC_SC_3_6 import AttributeChangeAccumulator
Expand All @@ -69,14 +69,6 @@ def _generate_verifier(passcode: int, salt: bytes, iterations: int) -> bytes:
return w0.to_bytes(NIST256p.baselen, byteorder='big') + L.to_bytes('uncompressed')


@dataclass
class _SetupParameters:
setup_qr_code: str
manual_code: int
discriminator: int
passcode: int


class TC_MCORE_FS_1_5(MatterBaseTest):
@async_test_body
async def setup_class(self):
Expand Down Expand Up @@ -106,11 +98,8 @@ async def setup_class(self):
self.dut_fsa_stdin = open(dut_fsa_stdin_pipe, "w")

self.th_server_port = th_server_port
# These are default testing values.
self.th_server_setup_params = _SetupParameters(
setup_qr_code="MT:-24J0AFN00KA0648G00",
manual_code=34970112332,
discriminator=3840,
self.th_server_setup_params = SetupParameters(
discriminator=random.randint(0, 4095),
passcode=20202021)

# Start the TH_SERVER app.
Expand All @@ -137,12 +126,12 @@ def teardown_class(self):
self.storage.cleanup()
super().teardown_class()

def _ask_for_vendor_commissioning_ux_operation(self, setup_params: _SetupParameters):
def _ask_for_vendor_commissioning_ux_operation(self, setup_params: SetupParameters):
self.wait_for_user_input(
prompt_msg=f"Using the DUT vendor's provided interface, commission the ICD device using the following parameters:\n"
f"- discriminator: {setup_params.discriminator}\n"
f"- setupPinCode: {setup_params.passcode}\n"
f"- setupQRCode: {setup_params.setup_qr_code}\n"
f"- setupQRCode: {setup_params.qr_code}\n"
f"- setupManualCode: {setup_params.manual_code}\n"
f"If using FabricSync Admin test app, you may type:\n"
f">>> pairing onnetwork 111 {setup_params.passcode}")
Expand Down

0 comments on commit 59c8c6c

Please sign in to comment.