This page provides an overview of the testing architecture, CI/CD integration, and quality assurance strategies for the BitChat codebase. It covers the in-memory networking harness used to make decentralized protocol testing deterministic and the automated workflows ensuring code quality.
For deep dives into specific testing areas, see the following child pages:
TestEnvironment detection), and the swift test workflow.NostrProtocolTests, cryptography verification (Noise handshakes), and protocol compliance validation.BLEServiceTests, MeshTopologyTrackerTests, and integration testing strategies.BitChat utilizes the Swift Testing framework for modern, async-native validation. The suite is designed to be deterministic and race-free by using an in-memory bus (MockBLEBus) that replaces physical Bluetooth hardware during test execution [bitchatTests/Mocks/MockBLEService.swift:30-30]. Global test detection is handled by TestEnvironment, which identifies when the app is running under XCTest, Swift Testing, or CI environments [bitchat/Services/TestEnvironment.swift:15-25].
| Component | Role in Testing | Code Entity |
|---|---|---|
| In-Memory Bus | Central exchange for simulated packet delivery | MockBLEBus [bitchatTests/Mocks/MockBLEService.swift:30-30] |
| Mock Service | Test-double for BLEService | MockBLEService [bitchatTests/Mocks/MockBLEService.swift:29-29] |
| Topology Manager | Controls peer links and adjacency | MockBLEBus.neighbors(of:) [bitchatTests/Mocks/MockBLEService.swift:69-71] |
| Test Helper | Orchestrates multi-node networks | TestNetworkHelper [bitchatTests/Integration/IntegrationTests.swift:17-17] |
The testing suite is divided into three primary layers:
BLEService initialization and peer connection state [bitchatTests/BLEServiceTests.swift:27-42].NoiseSessionManager [bitchatTests/EndToEnd/PrivateChatE2ETests.swift:112-127].Sources: [bitchatTests/Mocks/MockBLEService.swift:29-45], [bitchatTests/Integration/IntegrationTests.swift:15-24], [bitchatTests/BLEServiceTests.swift:14-23], [bitchat/Services/TestEnvironment.swift:15-25]
BitChat uses GitHub Actions for automated quality assurance. The workflow is defined in .github/workflows/swift-tests.yml and triggers on every push or pull request to the main branch [.github/workflows/swift-tests.yml:3-8].
Title: CI/CD Pipeline Flow
The pipeline runs tests in parallel across the app and local packages (BitLogger, BitFoundation) [.github/workflows/swift-tests.yml:22-30]. It utilizes actions/cache for build artifacts based on Package.resolved and source file hashes [.github/workflows/swift-tests.yml:43-51].
Performance Gating: Benchmarks are run serially to ensure stable numbers [.github/workflows/swift-tests.yml:99-104]. The check-perf-floors.sh script compares results against perf-floors.json to catch algorithmic regressions (e.g., O(n) to O(n²)) [scripts/check-perf-floors.sh:3-20]. A watchdog mechanism kills hung tests after 5 minutes to prevent runner starvation [.github/workflows/swift-tests.yml:68-95].
Sources: [.github/workflows/swift-tests.yml:1-133], [scripts/check-perf-floors.sh:1-182], [Package.swift:47-68]
The test suite ensures that cryptographic handshakes and binary packet structures are correctly handled.
NoiseSessionManager to establish encrypted channels [bitchatTests/EndToEnd/PrivateChatE2ETests.swift:112-127].TestHelpers provides utilities to generate valid BitchatPacket and BitchatMessage instances for protocol validation [bitchatTests/TestUtilities/TestHelpers.swift:18-57].The integration suite uses MockBLEService and TestNetworkHelper to simulate complex mesh topologies:
ttl (Time To Live) decrementing [bitchatTests/EndToEnd/PublicChatE2ETests.swift:137-158].Title: Testing Infrastructure Mapping
Title: Mock Mesh Interaction Sequence
Sources: [bitchatTests/Mocks/MockBLEService.swift:29-205], [bitchatTests/Integration/IntegrationTests.swift:15-54], [bitchatTests/EndToEnd/PublicChatE2ETests.swift:82-158], [bitchatTests/TestUtilities/TestHelpers.swift:14-133], [bitchatTests/BLEServiceTests.swift:65-120]
Refresh this wiki
This wiki was recently refreshed. Please wait 6 days to refresh again.