From 11595921139770d59f86ad42f6c85088d591f416 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Wed, 19 Jun 2024 16:26:32 +0200 Subject: [PATCH] [Python] Reset chip error in test commissioner (#34001) * [Python] Reset chip error in test commissioner Make sure to reset the chip error in test commissioner on reset. This avoid spurious errors. The Python side reads the error as soon as mTestCommissionerUsed is set, which happens unconditionally. Hence clearing the error is necessary. * [Python] Remove unexpected exception in TC_CGEN_2_4.py With the test commissioner properly resetting the error code the spurious exception is no longer thrown. Remove the exception handling from the test. --- src/controller/python/OpCredsBinding.cpp | 1 + src/python_testing/TC_CGEN_2_4.py | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/controller/python/OpCredsBinding.cpp b/src/controller/python/OpCredsBinding.cpp index 427ee9be46ba3c..f5815922cc14eb 100644 --- a/src/controller/python/OpCredsBinding.cpp +++ b/src/controller/python/OpCredsBinding.cpp @@ -259,6 +259,7 @@ class TestCommissioner : public chip::Controller::AutoCommissioner mPrematureCompleteAfter = chip::Controller::CommissioningStage::kError; mReadCommissioningInfo = chip::Controller::ReadCommissioningInfo(); mNeedsDST = false; + mCompletionError = CHIP_NO_ERROR; } bool GetTestCommissionerUsed() { return mTestCommissionerUsed; } void OnCommissioningSuccess(chip::PeerId peerId) { mReceivedCommissioningSuccess = true; } diff --git a/src/python_testing/TC_CGEN_2_4.py b/src/python_testing/TC_CGEN_2_4.py index fcfe2aaf044d3d..e9ab9d85c28e73 100644 --- a/src/python_testing/TC_CGEN_2_4.py +++ b/src/python_testing/TC_CGEN_2_4.py @@ -104,12 +104,9 @@ async def test_TC_CGEN_2_4(self): logging.info('Step 16 - TH2 fully commissions the DUT') self.th2.ResetTestCommissioner() - ctx = asserts.assert_raises(ChipStackError) - with ctx: - self.th2.CommissionOnNetwork( - nodeId=self.dut_node_id, setupPinCode=params.setupPinCode, - filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator) - asserts.assert_true(ctx.exception.chip_error.sdk_code == 0x02, 'Unexpected error code returned from CommissioningComplete') + self.th2.CommissionOnNetwork( + nodeId=self.dut_node_id, setupPinCode=params.setupPinCode, + filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.discriminator) logging.info('Commissioning complete done.') logging.info('Step 17 - TH1 sends an arm failsafe')