Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MacOMNI committed Jan 10, 2025
1 parent 0f9136d commit f0ab698
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public actor BlockchainDataProvider: Sendable {
if header.value.timeslot > bestHead.timeslot {
let number = try await dataProvider.getBlockNumber(hash: head).unwrap()
bestHead = HeadInfo(hash: head, timeslot: header.value.timeslot, number: number)
} else {
logger.warning("Found a block with timeslot \(header.value.timeslot) but best head is \(bestHead.timeslot)")
}
}

Expand Down
10 changes: 6 additions & 4 deletions Networking/Sources/Networking/Connection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public final class Connection<Handler: StreamHandler>: Sendable, ConnectionInfoP
let resp = try await impl.ephemeralStreamHandler.handle(connection: self, request: request)
try stream.send(message: resp, finish: true)
} catch {
logger.debug("Failed to handle request", metadata: ["error": "\(error)"])
logger.info("Failed to handle request", metadata: ["error": "\(error)"])
stream.close(abort: true)
}
}
Expand Down Expand Up @@ -318,7 +318,7 @@ private func receiveMaybeData(stream: Stream<some StreamHandler>) async throws -
// TODO: pick better value
guard length < 1024 * 1024 * 10 else {
stream.close(abort: true)
logger.debug("Invalid request length: \(length)")
logger.info("Invalid request length: \(length)")
// TODO: report bad peer
throw ConnectionError.invalidLength
}
Expand All @@ -336,7 +336,7 @@ func presistentStreamRunLoop<Handler: StreamHandler>(
do {
try await handler.streamOpened(connection: connection, stream: stream, kind: kind)
} catch {
logger.debug(
logger.error(
"Failed to setup presistent stream",
metadata: ["connectionId": "\(connection.id)", "streamId": "\(stream.id)", "kind": "\(kind)", "error": "\(error)"]
)
Expand All @@ -348,11 +348,13 @@ func presistentStreamRunLoop<Handler: StreamHandler>(
var decoder = handler.createDecoder(kind: kind)
do {
while let data = try await receiveMaybeData(stream: stream) {
logger.debug("receiveMaybeData length: \(data.count) from \(connection.id)")
let msg = try decoder.decode(data: data)
logger.debug("handling message: \(msg) from \(connection.id)")
try await handler.handle(connection: connection, message: msg)
}
} catch {
logger.debug("UP stream run loop failed: \(error)")
logger.error("UP stream run loop failed: \(error) from \(connection.id)")
stream.close(abort: true)
}

Expand Down
2 changes: 1 addition & 1 deletion Node/Sources/Node/NetworkingProtocol/Network.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ struct PresistentStreamHandlerImpl: PresistentStreamHandler {
}

func handle(connection: any ConnectionInfoProtocol, message: Message) async throws {
impl.logger.trace("handling message: \(message) from \(connection.id)")
impl.logger.debug("handling message: \(message) from \(connection.id)")

try await impl.handler.handle(connection: connection, upMessage: message)
}
Expand Down
2 changes: 1 addition & 1 deletion Node/Sources/Node/NetworkingProtocol/SyncManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public actor SyncManager: Sendable {
status = .syncing
syncContinuation.forEach { $0.resume() }
syncContinuation = []
logger.info("sync completed")
logger.debug("sync completed")
}
}

Expand Down
5 changes: 2 additions & 3 deletions Node/Tests/NodeTests/NodeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ final class NodeTests {
await middleware.wait()
}
}

let validator1BestHead = await validator1.dataProvider.bestHead
let validator2BestHead = await validator2.dataProvider.bestHead

Expand Down Expand Up @@ -217,7 +216,7 @@ final class NodeTests {
#expect(node1.network.peersCount == 19)
#expect(node2.network.peersCount == 19)
// Advance time to produce blocks
for _ in 0..<10 {
for _ in 0..<30 {
await scheduler.advance(
by: TimeInterval(validator1.blockchain.config.value.slotPeriodSeconds))
await validator1StoreMiddlware.wait()
Expand All @@ -227,7 +226,7 @@ final class NodeTests {
await middleware.wait()
}
}
try await Task.sleep(for: .milliseconds(nodes.count * 200))
try await Task.sleep(for: .milliseconds(nodes.count * 100))
let validator1BestHead = await validator1.dataProvider.bestHead
let validator2BestHead = await validator2.dataProvider.bestHead

Expand Down

0 comments on commit f0ab698

Please sign in to comment.