Skip to content

Commit

Permalink
Updated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Nov 15, 2024
1 parent f2fa2f9 commit 697126b
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions Tests/GATTTests/GATTTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ final class GATTTests: XCTestCase {
clientOptions: GATTCentralOptions(
maximumTransmissionUnit: clientMTU
), server: { peripheral in
_ = try await peripheral.add(service: service)
_ = peripheral.add(service: service)
}, client: { (central, peripheral) in
let services = try await central.discoverServices(for: peripheral)
let clientMTU = try await central.maximumTransmissionUnit(for: peripheral)
Expand Down Expand Up @@ -258,11 +258,11 @@ final class GATTTests: XCTestCase {

try await connect(
server: { peripheral in
let (serviceAttributeHandle, characteristicValueHandles) = try await peripheral.add(service: service)
let (serviceAttributeHandle, characteristicValueHandles) = peripheral.add(service: service)
serviceAttribute = serviceAttributeHandle
XCTAssertEqual(serviceAttribute, 1)
characteristicValueHandle = characteristicValueHandles[0]
peripheralDatabaseValue = { await peripheral[characteristic: characteristicValueHandle] }
peripheralDatabaseValue = { peripheral[characteristic: characteristicValueHandle] }
let currentValue = await peripheralDatabaseValue()
XCTAssertEqual(currentValue, characteristics[0].value)
peripheral.willWrite = {
Expand Down Expand Up @@ -334,12 +334,12 @@ final class GATTTests: XCTestCase {
serverOptions: .init(maximumTransmissionUnit: .default, maximumPreparedWrites: 1000),
clientOptions: .init(maximumTransmissionUnit: .max),
server: { peripheral in
let (serviceAttribute, characteristicValueHandles) = try await peripheral.add(service: service)
let (serviceAttribute, characteristicValueHandles) = peripheral.add(service: service)
XCTAssertEqual(serviceAttribute, 1)
let characteristicValueHandle = characteristicValueHandles[0]
Task {
try await Task.sleep(nanoseconds: 1_000_000_000)
await peripheral.write(newValue.data, forCharacteristic: characteristicValueHandle)
peripheral.write(newValue.data, forCharacteristic: characteristicValueHandle)
}
},
client: { (central, peripheral) in
Expand Down Expand Up @@ -399,12 +399,12 @@ final class GATTTests: XCTestCase {
serverOptions: .init(maximumTransmissionUnit: .default, maximumPreparedWrites: 1000),
clientOptions: .init(maximumTransmissionUnit: .max),
server: { peripheral in
let (serviceAttribute, characteristicValueHandles) = try await peripheral.add(service: service)
let (serviceAttribute, characteristicValueHandles) = peripheral.add(service: service)
XCTAssertEqual(serviceAttribute, 1)
let characteristicValueHandle = characteristicValueHandles[0]
Task {
try await Task.sleep(nanoseconds: 1_000_000_000)
await peripheral.write(newValue.data, forCharacteristic: characteristicValueHandle)
peripheral.write(newValue.data, forCharacteristic: characteristicValueHandle)
}
},
client: { (central, peripheral) in
Expand Down Expand Up @@ -469,7 +469,7 @@ final class GATTTests: XCTestCase {
serverOptions: .init(maximumTransmissionUnit: .default, maximumPreparedWrites: 1000),
clientOptions: .init(maximumTransmissionUnit: .default),
server: { peripheral in
let (serviceAttribute, _) = try await peripheral.add(service: service)
let (serviceAttribute, _) = peripheral.add(service: service)
XCTAssertEqual(serviceAttribute, 1)
},
client: { (central, peripheral) in
Expand Down Expand Up @@ -545,8 +545,8 @@ extension GATTTests {
peripheral.log = { print("Peripheral:", $0) }
try await server(peripheral)

try await peripheral.start()
defer { Task { await peripheral.stop() } }
peripheral.start()
defer { peripheral.stop() }

// central
let central = TestCentral(
Expand All @@ -566,7 +566,7 @@ extension GATTTests {
try await client(central, device.peripheral)
// cleanup
await central.disconnectAll()
await peripheral.removeAllServices()
peripheral.removeAllServices()
}

func test(
Expand Down

0 comments on commit 697126b

Please sign in to comment.