From d976b25b4855dc82ac547e9a7d6a38914a980777 Mon Sep 17 00:00:00 2001 From: Jeff Tung <100387939+jtung-apple@users.noreply.github.com> Date: Mon, 15 May 2023 21:51:18 -0700 Subject: [PATCH] [Darwin] Fix for MTRDevice attribute report omitting errors --- src/darwin/Framework/CHIP/MTRDevice.mm | 3 ++- src/darwin/Framework/CHIPTests/MTRDeviceTests.m | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDevice.mm index b9df4f0fdf40ab..9ca065238b4dd3 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.mm +++ b/src/darwin/Framework/CHIP/MTRDevice.mm @@ -912,7 +912,8 @@ - (NSArray *)_getAttributesToReportWithReportedValues:(NSArray *> * data) { + for (NSDictionary * attributeReponseValue in data) { + if (attributeReponseValue[MTRErrorKey]) { + [attributeReportErrorExpectation fulfill]; + } + } + }; + // use the nonexistent attribute and expect read error + [device readAttributeWithEndpointID:testEndpointID clusterID:testClusterID attributeID:testAttributeID params:nil]; + [self waitForExpectations:@[ attributeReportErrorExpectation ] timeout:10]; + // reset the onAttributeDataReceived to validate the following resubscribe test delegate.onAttributeDataReceived = ^(NSArray *> * data) { attributeReportsReceived += data.count;