Skip to content

Commit

Permalink
[Python] Reset chip error in test commissioner (project-chip#34001)
Browse files Browse the repository at this point in the history
* [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.
  • Loading branch information
agners authored and diogopintodsr committed Jun 19, 2024
1 parent 12ef2f9 commit adc1a49
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/controller/python/OpCredsBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
9 changes: 3 additions & 6 deletions src/python_testing/TC_CGEN_2_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit adc1a49

Please sign in to comment.