From 367addf1380e36afa2f15ac3d3e1b51578f2afa2 Mon Sep 17 00:00:00 2001 From: jack Date: Mon, 29 Sep 2025 11:50:41 +0200 Subject: [PATCH] Fix binary protocol test fixtures --- bitchatTests/NotificationStreamAssemblerTests.swift | 3 ++- bitchatTests/Protocol/BinaryProtocolTests.swift | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bitchatTests/NotificationStreamAssemblerTests.swift b/bitchatTests/NotificationStreamAssemblerTests.swift index 87736dc7..9c504a46 100644 --- a/bitchatTests/NotificationStreamAssemblerTests.swift +++ b/bitchatTests/NotificationStreamAssemblerTests.swift @@ -112,7 +112,8 @@ final class NotificationStreamAssemblerTests: XCTestCase { 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 eef9cbc2..39083c5e 100644 --- a/bitchatTests/Protocol/BinaryProtocolTests.swift +++ b/bitchatTests/Protocol/BinaryProtocolTests.swift @@ -90,7 +90,8 @@ final class BinaryProtocolTests: XCTestCase { } // The encoded size should be smaller than uncompressed due to compression - let uncompressedSize = BinaryProtocol.headerSize + BinaryProtocol.senderIDSize + largePayload.count + let headerSize = BinaryProtocol.headerSize(for: packet.version) + let uncompressedSize = headerSize + BinaryProtocol.senderIDSize + largePayload.count XCTAssertLessThan(encodedData.count, uncompressedSize) // Decode and verify