diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 15be3f29..ad3f6a80 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -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: | diff --git a/Networking/Tests/NetworkingTests/PeerTests.swift b/Networking/Tests/NetworkingTests/PeerTests.swift index ba541635..9312724d 100644 --- a/Networking/Tests/NetworkingTests/PeerTests.swift +++ b/Networking/Tests/NetworkingTests/PeerTests.swift @@ -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) @@ -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) @@ -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() { @@ -736,9 +736,9 @@ struct PeerTests { func broadcastSynchronization() async throws { var peers: [Peer] = [] 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( @@ -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(), @@ -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 {