feat: sync httpdns sdk/platform updates without large binaries

This commit is contained in:
robin
2026-03-04 17:59:14 +08:00
parent 853897a6f8
commit 532891fad0
700 changed files with 6096 additions and 2712 deletions

View File

@@ -0,0 +1,90 @@
//
// ScheduleCenterV6Test.m
// TrustHttpDNSTests
//
// Created by xuyecan on 2024/6/17.
// Copyright © 2024 trustapp.com. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <OCMock/OCMock.h>
#import "TestBase.h"
#import "HttpdnsHostObject.h"
#import "HttpdnsScheduleExecutor.h"
#import "HttpdnsScheduleCenter.h"
#import "HttpdnsService.h"
#import "HttpdnsService_Internal.h"
#import "HttpdnsUtil.h"
/**
* 使OCMockMock(使stopMocking)
* case<EFBFBD><EFBFBD>?
*/
@interface ScheduleCenterV6Test : TestBase
@end
@implementation ScheduleCenterV6Test
+ (void)setUp {
[super setUp];
}
+ (void)tearDown {
[super tearDown];
}
- (void)setUp {
[super setUp];
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
self.httpdns = [[HttpDnsService alloc] initWithAccountID:100000];
});
[self.httpdns setLogEnabled:YES];
[self.httpdns setReuseExpiredIPEnabled:NO];
[self.httpdns setLogHandler:self];
self.currentTimeStamp = [[NSDate date] timeIntervalSince1970];
}
- (void)tearDown {
[super tearDown];
}
- (void)testUpdateFailureWillMoveToNextUpdateServer {
[self presetNetworkEnvAsIpv6];
HttpdnsScheduleExecutor *realRequest = [HttpdnsScheduleExecutor new];
id mockRequest = OCMPartialMock(realRequest);
OCMStub([mockRequest fetchRegionConfigFromServer:[OCMArg any] error:(NSError * __autoreleasing *)[OCMArg anyPointer]])
.andReturn(nil);
id mockRequestClass = OCMClassMock([HttpdnsScheduleExecutor class]);
OCMStub([mockRequestClass new]).andReturn(mockRequest);
HttpdnsScheduleCenter *scheduleCenter = [[HttpdnsScheduleCenter alloc] initWithAccountId:100000];
NSArray<NSString *> *updateServerHostList = [scheduleCenter currentUpdateServerV4HostList];
int updateServerCount = (int)[updateServerHostList count];
XCTAssertGreaterThan(updateServerCount, 0);
// 2
[scheduleCenter asyncUpdateRegionScheduleConfigAtRetry:2];
[NSThread sleepForTimeInterval:0.1];
NSString *activeUpdateHost = [scheduleCenter getActiveUpdateServerHost];
// ipv4
XCTAssertFalse([HttpdnsUtil isIPv4Address:activeUpdateHost]);
OCMVerify([mockRequest fetchRegionConfigFromServer:[OCMArg any] error:(NSError * __autoreleasing *)[OCMArg anyPointer]]);
[NSThread sleepForTimeInterval:3];
}
@end