Skip to content

Commit f339612

Browse files
pre-commit-ci[bot]woody-apple
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent f6a46a5 commit f339612

3 files changed

Lines changed: 320 additions & 30 deletions

File tree

src/darwin/Framework/CHIP/MTRDevice_Concrete.mm

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,34 @@ - (void)unitTestSyncRunOnDeviceQueue:(dispatch_block_t)block
731731
{
732732
dispatch_sync(self.queue, block);
733733
}
734+
735+
// Test helper: parse a textual IP address and stash it as the cached
736+
// "last subscription IP" so the first-Thread-subscribe deferral gate's
737+
// cached-IP short-circuit can be exercised in pure-ObjC tests without
738+
// pulling C++ headers into the test sources. Pass nil to clear.
739+
- (void)unitTestSetLastSubscriptionIPAddressFromString:(NSString * _Nullable)addressString
740+
{
741+
std::lock_guard lock(_lock);
742+
if (addressString == nil) {
743+
_lastSubscriptionIPAddress.reset();
744+
return;
745+
}
746+
chip::Inet::IPAddress parsed;
747+
if (chip::Inet::IPAddress::FromString(addressString.UTF8String, parsed)) {
748+
_lastSubscriptionIPAddress = parsed;
749+
} else {
750+
_lastSubscriptionIPAddress.reset();
751+
}
752+
}
753+
754+
// Test helper: report whether the cached "last subscription IP" is set.
755+
// The underlying property is std::optional<chip::Inet::IPAddress> and
756+
// therefore not KVC-bridgeable into pure-ObjC tests.
757+
- (BOOL)unitTestHasCachedLastSubscriptionIPAddress
758+
{
759+
std::lock_guard lock(_lock);
760+
return _lastSubscriptionIPAddress.has_value();
761+
}
734762
#endif
735763

736764
#pragma mark - Time Synchronization

0 commit comments

Comments
 (0)