File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments