Skip to content

Commit

Permalink
Try increasing timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
sberrevoets committed Mar 20, 2024
1 parent 2a03721 commit 0b003ef
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Tests/KronosTests/NTPClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ final class NTPClientTests: XCTestCase {
DNSResolver.resolve(host: "time.apple.com") { addresses in
XCTAssertGreaterThan(addresses.count, 0)

NTPClient().query(ip: addresses.first!, version: 3, numberOfSamples: 1) { PDU in
NTPClient().query(ip: addresses.first!, timeout: 20, version: 3, numberOfSamples: 1) { PDU in
XCTAssertNotNil(PDU)

XCTAssertGreaterThanOrEqual(PDU!.version, 3)
Expand All @@ -19,32 +19,33 @@ final class NTPClientTests: XCTestCase {
}
}

self.waitForExpectations(timeout: 10)
self.waitForExpectations(timeout: 20)
}

func testQueryPool() {
let expectation = self.expectation(description: "Offset from ref clock to local clock are accurate")
NTPClient().query(pool: "0.pool.ntp.org", numberOfSamples: 1, maximumServers: 1) { offset, _, _ in
XCTAssertNotNil(offset)

NTPClient().query(pool: "0.pool.ntp.org", numberOfSamples: 1, maximumServers: 1)
NTPClient().query(pool: "0.pool.ntp.org", numberOfSamples: 1, maximumServers: 1, timeout: 20)
{ offset2, _, _ in
XCTAssertNotNil(offset2)
XCTAssertLessThan(abs(offset! - offset2!), 0.10)
expectation.fulfill()
}
}

self.waitForExpectations(timeout: 10)
self.waitForExpectations(timeout: 20)
}

func testQueryPoolWithIPv6() {
let expectation = self.expectation(description: "NTPClient queries a pool that supports IPv6")
NTPClient().query(pool: "2.pool.ntp.org", numberOfSamples: 1, maximumServers: 1) { offset, _, _ in
NTPClient().query(pool: "2.pool.ntp.org", numberOfSamples: 1, maximumServers: 1, timeout: 20)
{ offset, _, _ in
XCTAssertNotNil(offset)
expectation.fulfill()
}

self.waitForExpectations(timeout: 10)
self.waitForExpectations(timeout: 20)
}
}

0 comments on commit 0b003ef

Please sign in to comment.