Initial commit: NetworkCity — network traffic as a neon city
A native macOS network monitor that renders live traffic as a top-down neon city: your Mac is downtown, remote orgs are glowing districts, and traffic is cars of light driving the roads. Architecture: - NetworkCityCore: swappable data layer behind a ConnectionSource protocol (nettop-backed today), plus pure/tested logic — traffic diffing, org classification (reverse-DNS + CIDR), traffic classes, hub-and-spoke expansion policy, label anti-overlap, and latency→distance layout. - NetworkCityApp: SwiftUI + SpriteKit city — auto-expanding districts, protocol-coloured cars, click-to-inspect panel, and latency-as-distance (districts glide to their measured RTT). - nettop-probe: CLI proof of the data layer. 44 tests passing. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import XCTest
|
||||
@testable import NetworkCityCore
|
||||
|
||||
final class TrafficClassTests: XCTestCase {
|
||||
|
||||
func testQuicByProtocol() {
|
||||
XCTAssertEqual(TrafficClass.classify(proto: .quic4, port: 443), .quic)
|
||||
XCTAssertEqual(TrafficClass.classify(proto: .quic6, port: 12345), .quic)
|
||||
}
|
||||
|
||||
func testHTTPSOverTCP() {
|
||||
XCTAssertEqual(TrafficClass.classify(proto: .tcp4, port: 443), .https)
|
||||
}
|
||||
|
||||
func testUDP443IsQuic() {
|
||||
XCTAssertEqual(TrafficClass.classify(proto: .udp4, port: 443), .quic)
|
||||
}
|
||||
|
||||
func testDNS() {
|
||||
XCTAssertEqual(TrafficClass.classify(proto: .udp4, port: 53), .dns)
|
||||
XCTAssertEqual(TrafficClass.classify(proto: .udp6, port: 5353), .dns)
|
||||
XCTAssertEqual(TrafficClass.classify(proto: .tcp4, port: 53), .dns)
|
||||
}
|
||||
|
||||
func testHTTP() {
|
||||
XCTAssertEqual(TrafficClass.classify(proto: .tcp4, port: 80), .http)
|
||||
XCTAssertEqual(TrafficClass.classify(proto: .tcp4, port: 8080), .http)
|
||||
}
|
||||
|
||||
func testOther() {
|
||||
XCTAssertEqual(TrafficClass.classify(proto: .tcp4, port: 22), .other)
|
||||
XCTAssertEqual(TrafficClass.classify(proto: .tcp4, port: nil), .other)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user