mirror of
https://github.com/shadowsocks/ShadowsocksX-NG.git
synced 2026-11-02 00:04:46 +00:00
test: drop assertions that restate the language or a fixture
Each removed assertion holds by construction and can never fail: - jsonData() compared with itself cannot detect cross-run byte stability; bindAddress and mode are literal-returning computed properties - RuleAction/RuleSourceKind allCases assertions pin synthesized enum order (neither allCases list is used in production); the persisted action tokens stay pinned by the kept rawValue assertions and source-kind tokens by fixture decoding through RuleSnapshotStore - memberwise-constructor echo in RuleSourceIdentity, fixture-guaranteed name == id rows, a share draft field pair built from one string, and a local struct compared to its own assignment - the synthesized-Codable round trip through literal JSONEncoder/JSONDecoder The duplicate-import assertion becomes a real check: Set of node ids instead of a count that restated roots.count, which is what its comment claims. Co-Authored-By: DeepSeek Harness <noreply@deepseek.com>
This commit is contained in:
co-authored by
DeepSeek Harness
parent
e7116a5ebd
commit
78bafea90f
@@ -45,7 +45,6 @@ final class CatalogTreeProjectionTests: XCTestCase {
|
||||
rows.map(\.id.rawValue),
|
||||
["root-server", "outer", "inner", "deep-leaf", "outer-leaf", "empty"])
|
||||
XCTAssertEqual(rows.map(\.depth), [0, 0, 1, 2, 1, 0])
|
||||
XCTAssertEqual(rows.map(\.node.name), rows.map(\.id.rawValue), "行身份即节点身份")
|
||||
}
|
||||
|
||||
func testVisibleRowsSkipCollapsedSubtrees() {
|
||||
|
||||
@@ -274,7 +274,6 @@ struct ConfigurationGroupSharingTests {
|
||||
#expect(uris[1].pluginProgram == "missing-plugin")
|
||||
#expect(uris[1].pluginOptions == "mode=websocket;host=example.com")
|
||||
#expect(uris[1].remark == "嵌套服务器")
|
||||
#expect(draft.uriList.data == Data(draft.uriText.utf8))
|
||||
#expect(draft.uriList.suggestedFileName == "组 根.txt")
|
||||
#expect(draft.uriList.format == .uriList)
|
||||
let node = try #require(fixture.workflow.tree.node(withID: fixture.root))
|
||||
|
||||
@@ -127,8 +127,6 @@ final class LegacyImportTests: XCTestCase {
|
||||
XCTAssertEqual(try makeTestCatalogStore(fileURL: catalogURL).load().catalog, originalCatalog)
|
||||
XCTAssertEqual(
|
||||
try ActivationStateFileStore(fileURL: activationURL).loadActiveTargetID(), originalID)
|
||||
XCTAssertEqual(
|
||||
originalServerFields.password, "original-password")
|
||||
XCTAssertFalse(marker.completed)
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ struct CatalogWorkflowImportTests {
|
||||
|
||||
#expect(workflow.tree.roots.count == 2)
|
||||
#expect(workflow.tree.roots.map(\.name) == ["我的机场", "我的机场 2"], "重名加序号后缀")
|
||||
#expect(workflow.tree.roots.map(\.id).count == 2, "重复导入产生独立副本(ADR-0027)")
|
||||
#expect(Set(workflow.tree.roots.map(\.id)).count == 2, "重复导入产生独立副本(ADR-0027)")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ final class ProxyRuleTests: XCTestCase {
|
||||
// MARK: - 动作与匹配
|
||||
|
||||
func testActionsAreProxyAndDirect() throws {
|
||||
XCTAssertEqual(RuleAction.allCases, [.proxy, .direct])
|
||||
XCTAssertEqual(RuleAction.proxy.rawValue, "proxy")
|
||||
XCTAssertEqual(RuleAction.direct.rawValue, "direct")
|
||||
}
|
||||
@@ -69,24 +68,6 @@ final class ProxyRuleTests: XCTestCase {
|
||||
XCTAssertThrowsError(try RuleMatch(ipv6CIDR: "gggg::/32"))
|
||||
}
|
||||
|
||||
// MARK: - 来源身份
|
||||
|
||||
func testSourceIdentityCapturesKindAndUpstream() throws {
|
||||
let source = RuleSourceIdentity(
|
||||
kind: .geolocationCN,
|
||||
upstreamVersion: "20260925234224",
|
||||
label: "geolocation-cn")
|
||||
XCTAssertEqual(source.kind, .geolocationCN)
|
||||
XCTAssertEqual(source.upstreamVersion, "20260925234224")
|
||||
XCTAssertEqual(source.id, "geolocation-cn")
|
||||
}
|
||||
|
||||
func testSourceKindsCoverBuiltInAndCustom() throws {
|
||||
XCTAssertEqual(
|
||||
RuleSourceKind.allCases,
|
||||
[.geolocationCN, .chinaIPv4, .gfwlist, .custom])
|
||||
}
|
||||
|
||||
// MARK: - 规则序列化
|
||||
|
||||
func testCustomRuleStorageKeepsFlatActionAndMatch() throws {
|
||||
|
||||
@@ -69,12 +69,6 @@ final class RuntimeDocumentTests: XCTestCase {
|
||||
XCTAssertFalse(server.keys.contains("plugin_opts"))
|
||||
}
|
||||
|
||||
func testJSONDataIsStableAcrossEncodes() throws {
|
||||
let document = makeDocument(plugin: "/bundle/plugins/x")
|
||||
|
||||
XCTAssertEqual(try document.jsonData(), try document.jsonData(), "编码确定性(sortedKeys)")
|
||||
}
|
||||
|
||||
// MARK: 监听设置透传
|
||||
|
||||
func testRuntimeDocumentLeavesTimeoutAndLoggingAtUpstreamDefaults() throws {
|
||||
@@ -111,7 +105,6 @@ final class RuntimeDocumentTests: XCTestCase {
|
||||
socksPort: 1086,
|
||||
httpPort: 1087)
|
||||
|
||||
XCTAssertEqual(listen.bindAddress, "127.0.0.1")
|
||||
XCTAssertEqual(
|
||||
listen.locals,
|
||||
[
|
||||
@@ -130,7 +123,6 @@ final class RuntimeDocumentTests: XCTestCase {
|
||||
socksPort: 1086,
|
||||
httpPort: 1087)
|
||||
|
||||
XCTAssertEqual(listen.bindAddress, "127.0.0.1")
|
||||
XCTAssertEqual(Set(listen.locals.map(\.localAddress)), ["127.0.0.1", "0.0.0.0"])
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ final class ProxyListeningFileStoreTests: XCTestCase {
|
||||
try store.save(settings)
|
||||
|
||||
XCTAssertEqual(try store.load(), settings)
|
||||
XCTAssertEqual(try store.load().mode, "tcp_and_udp")
|
||||
}
|
||||
|
||||
func testEncryptedListeningHasItsOwnFile() {
|
||||
|
||||
@@ -10,7 +10,6 @@ final class ProxyRuntimeSettingsTests: XCTestCase {
|
||||
|
||||
XCTAssertEqual(settings.listen.socksPort, 11086)
|
||||
XCTAssertEqual(settings.listen.httpPort, 11087)
|
||||
XCTAssertEqual(settings.listen.mode, "tcp_and_udp")
|
||||
XCTAssertFalse(settings.agentEnabled, "全新用户无服务器配置,Agent 默认 off")
|
||||
XCTAssertFalse(settings.systemProxyEnabled)
|
||||
XCTAssertTrue(settings.validationErrors.isEmpty)
|
||||
|
||||
@@ -2,8 +2,8 @@ import XCTest
|
||||
|
||||
@testable import ShadowsocksX_NG2
|
||||
|
||||
/// helper XPC 契约测试:typed payload 往返、引擎应答编码与
|
||||
/// 串行 last-writer 语义,全部用确定性替身,不触真实 XPC 与 SystemConfiguration。
|
||||
/// helper XPC 契约测试:引擎应答编码、typed 失败归并与串行
|
||||
/// last-writer 语义,全部用确定性替身,不触真实 XPC 与 SystemConfiguration。
|
||||
final class SystemProxyHelperContractTests: XCTestCase {
|
||||
private let configuration = SystemProxyConfiguration(
|
||||
socks: .init(host: "127.0.0.1", port: 1086),
|
||||
@@ -29,14 +29,7 @@ final class SystemProxyHelperContractTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
func testConfigurationPayloadRoundTripsThroughJSON() throws {
|
||||
let payload = try SystemProxyHelperWire.encodeConfiguration(configuration)
|
||||
let decoded = try SystemProxyHelperWire.decodeConfiguration(payload)
|
||||
XCTAssertEqual(decoded, configuration)
|
||||
}
|
||||
|
||||
func testEngineAnswersApplyWithTypedOutcome() throws {
|
||||
let requested = try SystemProxyHelperWire.encodeConfiguration(configuration)
|
||||
let observed = LockedArray<SystemProxyHelperEngine.Request>()
|
||||
let response = SystemProxyHelperEngine.response(
|
||||
request: .success(.apply(configuration)),
|
||||
@@ -47,9 +40,6 @@ final class SystemProxyHelperContractTests: XCTestCase {
|
||||
|
||||
XCTAssertEqual(observed.all, [.apply(configuration)], "helper 收到 closed typed 配置")
|
||||
XCTAssertEqual(response, .applied(.written))
|
||||
XCTAssertEqual(
|
||||
try SystemProxyHelperWire.decodeConfiguration(requested), configuration,
|
||||
"payload 与配置一致")
|
||||
}
|
||||
|
||||
func testEngineAnswersClearWithTypedOutcome() {
|
||||
|
||||
Reference in New Issue
Block a user