recordAndTakeMessageIDForMatchingPacket (Services/BLESelfBroadcastTrackerTests.swift)

bitchat · bitchatTests/Services/BLESelfBroadcastTrackerTests.swift · swift · Unlicense
pos

Module exposing: recordAndTakeMessageIDForMatchingPacket, differentPacketDoesNotResolveMessageID, pruneRemovesEntriesBeforeCutoff, removeAllClearsTrackedMessages

// Source: https://github.com/permissionlesstech/bitchat | License: Unlicense
// Provided via justclaw.it.com; keep this notice with the code.
import BitFoundation
import Foundation
import Testing
@testable import bitchat

struct BLESelfBroadcastTrackerTests {
    @Test
    func recordAndTakeMessageIDForMatchingPacket() {
        let packet = makePacket(timestamp: 1234)
        var tracker = BLESelfBroadcastTracker()

        tracker.record(messageID: "local-message", packet: packet, sentAt: Date())

        #expect(tracker.takeMessageID(for: packet) == "local-message")
        #expect(tracker.takeMessageID(for: packet) == nil)
        #expect(tracker.isEmpty)
    }

    @Test
    func differentPacketDoesNotResolveMessageID() {
        let packet = makePacket(timestamp: 1234)
        let o

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key