Skip to content

Commit

Permalink
update coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
MacOMNI committed Nov 11, 2024
1 parent 901ec6f commit 67728a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
15 changes: 5 additions & 10 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,11 @@ jobs:
run: make deps
- name: Test Coverage
run: |
for package in $(find . -name Package.swift -exec dirname {} \;); do
cd $package
if [ -d "Tests" ] && [ "$(find Tests -name '*.swift' | xargs grep -l '#expect' | wc -l)" -gt 0 ]; then
echo "Running tests in $package"
swift test --enable-code-coverage --parallel || echo "Tests timed out or failed in $package"
else
echo "Skipping $package: No valid test cases found"
fi
cd -
done
for file in **/Package.swift; do
cd $(dirname "$file")
swift test --enable-test-discovery
cd -
done
- name: Merge Coverage Reports
run: |
Expand Down
16 changes: 8 additions & 8 deletions Networking/Tests/NetworkingTests/PeerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ struct PeerTests {
let connection = try peer1.connect(
to: peer2.listenAddress(), role: .validator
)
try? await Task.sleep(for: .milliseconds(100))
try? await Task.sleep(for: .milliseconds(1000))

let receivedData = try await connection.request(
MockRequest(kind: .typeA, data: messageData)
Expand Down Expand Up @@ -391,7 +391,7 @@ struct PeerTests {
let connection = try peer1.connect(
to: peer2.listenAddress(), role: .validator
)
try? await Task.sleep(for: .milliseconds(100))
try? await Task.sleep(for: .milliseconds(1000))

let receivedData = try await connection.request(
MockRequest(kind: .typeA, data: messageData)
Expand Down Expand Up @@ -614,7 +614,7 @@ struct PeerTests {
}

// Wait for message propagation
try? await Task.sleep(for: .milliseconds(100))
try? await Task.sleep(for: .milliseconds(1000))

// everyone should receive two messages
for (idx, handler) in handlers.enumerated() {
Expand Down Expand Up @@ -736,9 +736,9 @@ struct PeerTests {
func broadcastSynchronization() async throws {
var peers: [Peer<MockStreamHandler>] = []
var handles: [MockPresentStreamHandler] = []

let peersCount = 50
// Create 50 peers with unique addresses
for _ in 0 ..< 50 {
for _ in 0 ..< peersCount {
let handle = MockPresentStreamHandler()
let peer = try Peer(
options: PeerOptions<MockStreamHandler>(
Expand All @@ -757,9 +757,9 @@ struct PeerTests {
}

// Connect each peer to form a fully connected network
for i in 0 ..< peers.count {
for i in 0 ..< peersCount {
let peer = peers[i]
for j in 0 ..< peers.count where i > j {
for j in i + 1 ..< peersCount {
let otherPeer = peers[j]
let conn = try peer.connect(
to: otherPeer.listenAddress(),
Expand All @@ -775,7 +775,7 @@ struct PeerTests {
centralPeer.broadcast(kind: .uniqueA, message: MockRequest(kind: .uniqueA, data: messagedata))

// Wait for message to propagate
try? await Task.sleep(for: .seconds(1))
try? await Task.sleep(for: .seconds(2))

// Check that each peer received the broadcast
for i in 1 ..< handles.count {
Expand Down

0 comments on commit 67728a6

Please sign in to comment.