From fbc15ea08f7b438238f979138b67aac5851de5ac Mon Sep 17 00:00:00 2001 From: Islam <2553451+qalandarov@users.noreply.github.com> Date: Tue, 7 Oct 2025 11:40:20 +0100 Subject: [PATCH] SwiftTesting: Enable in GitHubActions + peer uuids (#767) --- .github/workflows/swift-tests.yml | 2 +- bitchatTests/EndToEnd/PrivateChatE2ETests.swift | 11 +++++------ bitchatTests/EndToEnd/PublicChatE2ETests.swift | 13 ++++++------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/.github/workflows/swift-tests.yml b/.github/workflows/swift-tests.yml index 08ddd0c8..372e4b0e 100644 --- a/.github/workflows/swift-tests.yml +++ b/.github/workflows/swift-tests.yml @@ -24,4 +24,4 @@ jobs: run: swift build - name: Run Tests - run: swift test --parallel --disable-swift-testing # so it only runs xctests: https://github.com/swiftlang/swift-package-manager/issues/8529#issuecomment-2815711345 + run: swift test --parallel diff --git a/bitchatTests/EndToEnd/PrivateChatE2ETests.swift b/bitchatTests/EndToEnd/PrivateChatE2ETests.swift index de2ec9f4..31b29b29 100644 --- a/bitchatTests/EndToEnd/PrivateChatE2ETests.swift +++ b/bitchatTests/EndToEnd/PrivateChatE2ETests.swift @@ -8,6 +8,7 @@ import Testing import CryptoKit +import struct Foundation.UUID @testable import bitchat // TODO: Remove once MockBLEService is refactored to fix race condition @@ -20,12 +21,10 @@ struct PrivateChatE2ETests { private let mockKeychain: MockKeychain init() { - MockBLEService.resetTestBus() - - // Create services with unique peer IDs to avoid collision with other test suites - alice = MockBLEService(peerID: "PRIV_ALICE_", nickname: TestConstants.testNickname1) - bob = MockBLEService(peerID: "PRIV_BOB___", nickname: TestConstants.testNickname2) - charlie = MockBLEService(peerID: "PRIV_CHARLE", nickname: TestConstants.testNickname3) + // Create services with unique peer IDs to avoid any collision + alice = MockBLEService(peerID: PeerID(str: UUID().uuidString), nickname: TestConstants.testNickname1) + bob = MockBLEService(peerID: PeerID(str: UUID().uuidString), nickname: TestConstants.testNickname2) + charlie = MockBLEService(peerID: PeerID(str: UUID().uuidString), nickname: TestConstants.testNickname3) mockKeychain = MockKeychain() } diff --git a/bitchatTests/EndToEnd/PublicChatE2ETests.swift b/bitchatTests/EndToEnd/PublicChatE2ETests.swift index 48c5f0fb..728c7ce9 100644 --- a/bitchatTests/EndToEnd/PublicChatE2ETests.swift +++ b/bitchatTests/EndToEnd/PublicChatE2ETests.swift @@ -7,6 +7,7 @@ // import Testing +import struct Foundation.UUID @testable import bitchat @Suite(.serialized) @@ -20,13 +21,11 @@ struct PublicChatE2ETests { private var receivedMessages: [String: [BitchatMessage]] = [:] init() { - MockBLEService.resetTestBus() - - // Create mock services with unique peer IDs to avoid collision with other test suites - alice = MockBLEService(peerID: "PUB_ALICE__", nickname: TestConstants.testNickname1) - bob = MockBLEService(peerID: "PUB_BOB____", nickname: TestConstants.testNickname2) - charlie = MockBLEService(peerID: "PUB_CHARLIE", nickname: TestConstants.testNickname3) - david = MockBLEService(peerID: "PUB_DAVID__", nickname: TestConstants.testNickname4) + // Create mock services with unique peer IDs to avoid any collision + alice = MockBLEService(peerID: PeerID(str: UUID().uuidString), nickname: TestConstants.testNickname1) + bob = MockBLEService(peerID: PeerID(str: UUID().uuidString), nickname: TestConstants.testNickname2) + charlie = MockBLEService(peerID: PeerID(str: UUID().uuidString), nickname: TestConstants.testNickname3) + david = MockBLEService(peerID: PeerID(str: UUID().uuidString), nickname: TestConstants.testNickname4) } // MARK: - Basic Broadcasting Tests