diff --git a/bitchatTests/NotificationStreamAssemblerTests.swift b/bitchatTests/NotificationStreamAssemblerTests.swift index 07d3b00c..e366bb94 100644 --- a/bitchatTests/NotificationStreamAssemblerTests.swift +++ b/bitchatTests/NotificationStreamAssemblerTests.swift @@ -99,7 +99,8 @@ struct NotificationStreamAssemblerTests { func testAssemblesCompressedLargeFrame() throws { var assembler = NotificationStreamAssembler() - let largeContent = Data(repeating: 0x41, count: 2_500_000) + // Keep the fixture below FileTransferLimits.maxPayloadBytes so encoding succeeds while still exercising compression. + let largeContent = Data(repeating: 0x41, count: 600_000) let filePacket = BitchatFilePacket( fileName: "large.bin", fileSize: UInt64(largeContent.count), diff --git a/bitchatTests/Protocol/BinaryProtocolTests.swift b/bitchatTests/Protocol/BinaryProtocolTests.swift index 0c7f5751..27ccaebd 100644 --- a/bitchatTests/Protocol/BinaryProtocolTests.swift +++ b/bitchatTests/Protocol/BinaryProtocolTests.swift @@ -68,8 +68,9 @@ struct BinaryProtocolTests { let encodedData = try #require(BinaryProtocol.encode(packet), "Failed to encode packet with large payload") // The encoded size should be smaller than uncompressed due to compression - let uncompressedSize = BinaryProtocol.headerSize + BinaryProtocol.senderIDSize + largePayload.count - #expect(encodedData.count < uncompressedSize) + let headerSize = BinaryProtocol.headerSize(for: packet.version) + let uncompressedSize = headerSize + BinaryProtocol.senderIDSize + largePayload.count + #expect(encodedData.count < uncompressedSize, "Compressed packet should be smaller than uncompressed form") // Decode and verify let decodedPacket = try #require(BinaryProtocol.decode(encodedData), "Failed to decode compressed packet")