Skip to content

Commit 8df8d47

Browse files
add test
1 parent 10db778 commit 8df8d47

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

src/app/ReadClient.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,6 @@ void ReadClient::OnActiveModeNotification()
494494
}
495495

496496
TriggerResubscribeIfScheduled("check-in message");
497-
return;
498497
}
499498

500499
void ReadClient::OnPeerTypeChange(PeerType aType)

src/controller/tests/data_model/TestRead.cpp

+49
Original file line numberDiff line numberDiff line change
@@ -4626,4 +4626,53 @@ System::Clock::Timeout TestRead::ComputeSubscriptionTimeout(System::Clock::Secon
46264626
return publisherTransmissionTimeout + aMaxInterval + System::Clock::Milliseconds32(1000);
46274627
}
46284628

4629+
TEST_F(TestRead, TestSubscribeAttributeErrorWithResubWhenCheckIn)
4630+
{
4631+
auto sessionHandle = GetSessionBobToAlice();
4632+
4633+
{
4634+
TestResubscriptionCallback callback;
4635+
ReadClient readClient(InteractionModelEngine::GetInstance(), &GetExchangeManager(), callback,
4636+
ReadClient::InteractionType::Subscribe);
4637+
4638+
callback.SetReadClient(&readClient);
4639+
4640+
ReadPrepareParams readPrepareParams(GetSessionBobToAlice());
4641+
4642+
// Read full wildcard paths, repeat twice to ensure chunking.
4643+
AttributePathParams attributePathParams[1];
4644+
readPrepareParams.mpAttributePathParamsList = attributePathParams;
4645+
readPrepareParams.mAttributePathParamsListSize = MATTER_ARRAY_SIZE(attributePathParams);
4646+
attributePathParams[0].mEndpointId = kTestEndpointId;
4647+
attributePathParams[0].mClusterId = Clusters::UnitTesting::Id;
4648+
attributePathParams[0].mAttributeId = Clusters::UnitTesting::Attributes::Boolean::Id;
4649+
readPrepareParams.mIsPeerLIT = true;
4650+
constexpr uint16_t maxIntervalCeilingSeconds = 1;
4651+
4652+
readPrepareParams.mMaxIntervalCeilingSeconds = maxIntervalCeilingSeconds;
4653+
4654+
EXPECT_EQ(callback.mOnResubscriptionsAttempted, 0);
4655+
4656+
auto err = readClient.SendAutoResubscribeRequest(std::move(readPrepareParams));
4657+
EXPECT_EQ(err, CHIP_NO_ERROR);
4658+
{
4659+
ScopedChange directive(gReadResponseDirective, ReadResponseDirective::kSendDataError);
4660+
DrainAndServiceIO();
4661+
EXPECT_EQ(callback.mOnResubscriptionsAttempted, 1);
4662+
EXPECT_EQ(callback.mOnSubscriptionEstablishedCount, 0);
4663+
}
4664+
4665+
{
4666+
ScopedChange directive(gReadResponseDirective, ReadResponseDirective::kSendDataResponse);
4667+
InteractionModelEngine::GetInstance()->OnActiveModeNotification(
4668+
ScopedNodeId(readClient.GetPeerNodeId(), readClient.GetFabricIndex()));
4669+
DrainAndServiceIO();
4670+
EXPECT_EQ(callback.mOnSubscriptionEstablishedCount, 1);
4671+
}
4672+
4673+
EXPECT_EQ(callback.mOnError, 0);
4674+
EXPECT_EQ(callback.mOnDone, 0);
4675+
}
4676+
}
4677+
46294678
} // namespace

0 commit comments

Comments
 (0)