Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion swift/TailscaleKit/OutgoingConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ public actor OutgoingConnection {
throw TailscaleError.connectionClosed
}

let bytesWritten = Darwin.write(conn, data.withUnsafeBytes { $0.baseAddress! }, data.count)
let bytesWritten = data.withUnsafeBytes { bytes in
Darwin.write(conn, bytes.baseAddress, bytes.count)
}

if bytesWritten != data.count {
throw TailscaleError.shortWrite
Expand Down
11 changes: 7 additions & 4 deletions swift/TailscaleKitXCTests/TailscaleKitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ final class TailscaleKitTests: XCTestCase {
try await runConnectionTests(for: .v6)
}

func runConnectionTests(for netType: IPAddrType) async throws {
let logger = BlackholeLogger()
func testSendShortMessage() async throws {
try await runConnectionTests(for: .v4, message: Data("ping".utf8))
}

let want = "Hello Tailscale".data(using: .utf8)!
func runConnectionTests(for netType: IPAddrType,
message want: Data = Data("Hello Tailscale".utf8)) async throws {
let logger = BlackholeLogger()

do {
let ts1 = try TailscaleNode(config: mockConfig(), logger: logger)
Expand Down Expand Up @@ -95,7 +98,7 @@ final class TailscaleKitTests: XCTestCase {

let got = try await inbound.receiveMessage(timeout: 2)
print("got \(got)")
XCTAssert(got == want)
XCTAssertEqual(got, want)

msgReceived.fulfill()
}
Expand Down