From 9cf9ce8fa3001914bd6c7294069be9e01eec4e18 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 25 Jun 2021 22:12:27 -0400 Subject: [PATCH] Use CASE for our "Tests" test suite. (#7896) There are four changes here: 1) When doing onnetwork commissioning, make sure to run the part of the commissioning state machine that is meant to run on the operational network, starting with the mdns resolution of the device operational address. This ensures that we put ourselves into a state where we know the operational cert is fully provisioned on the device and we can talk to it via CASE. 2) Fix the fabric id in the script's pairing command to match the fabric id all-clusters-app advertises, so our operational discovery looks for the right thing. 3) Ensure that we actually start operational advertisement when we get a new opcert. Just restarting our mdns server does not do that, due to https://github.com/project-chip/connectedhomeip/issues/7911 4) Don't fail out on UpdateAddress attempts when there is no connection; that's not an error condition and should not be communicated as such to consumers. --- .../chip-tool/commands/pairing/PairingCommand.cpp | 12 +++++++++--- scripts/tests/test_suites.sh | 2 +- .../operational-credentials-server.cpp | 2 +- src/controller/CHIPDevice.cpp | 9 ++++++++- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/examples/chip-tool/commands/pairing/PairingCommand.cpp b/examples/chip-tool/commands/pairing/PairingCommand.cpp index 51c6080fc678c5..f21554299fcd45 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.cpp +++ b/examples/chip-tool/commands/pairing/PairingCommand.cpp @@ -110,11 +110,15 @@ void PairingCommand::OnPairingComplete(CHIP_ERROR err) if (err == CHIP_NO_ERROR) { ChipLogProgress(chipTool, "Pairing Success"); - SetupNetwork(); + err = SetupNetwork(); } else { ChipLogProgress(chipTool, "Pairing Failure: %s", ErrorStr(err)); + } + + if (err != CHIP_NO_ERROR) + { SetCommandExitStatus(err); } } @@ -156,8 +160,10 @@ CHIP_ERROR PairingCommand::SetupNetwork() { case PairingNetworkType::None: case PairingNetworkType::Ethernet: - // Nothing to do - SetCommandExitStatus(err); + // Nothing to do other than to resolve the device's operational address. + err = UpdateNetworkAddress(); + VerifyOrExit(err == CHIP_NO_ERROR, + ChipLogError(chipTool, "Setup failure! Error calling UpdateNetworkAddress: %s", ErrorStr(err))); break; case PairingNetworkType::WiFi: case PairingNetworkType::Thread: diff --git a/scripts/tests/test_suites.sh b/scripts/tests/test_suites.sh index a8404345451c3b..0aa875e183dcee 100755 --- a/scripts/tests/test_suites.sh +++ b/scripts/tests/test_suites.sh @@ -88,7 +88,7 @@ for j in "${iter_array[@]}"; do # the data is there yet. background_pid="$(GetPeerConnectionState(mSecureSession); - VerifyOrReturnError(connectionState != nullptr, CHIP_ERROR_INCORRECT_STATE); + if (connectionState == nullptr) + { + // Nothing needs to be done here. It's not an error to not have a + // connectionState. For one thing, we could have gotten an different + // UpdateAddress already and that caused connections to be torn down and + // whatnot. + return CHIP_NO_ERROR; + } mDeviceAddress = addr; connectionState->SetPeerAddress(addr);