test: use v2 packet for regression test and add limit note

This commit is contained in:
Harsh Jain 2026-08-03 19:10:59 +05:30
parent b30670a671
commit d32021049e
3 changed files with 6 additions and 3 deletions

View File

@ -7,6 +7,7 @@ public enum FileTransferLimits {
/// Compressed images after downscaling should comfortably fit under this budget.
public static let maxImageBytes: Int = 512 * 1024 // 512 KiB
/// Worst-case size once TLV metadata and binary packet framing are included for the largest payloads.
/// Note: This is now a hard expanded-size ceiling rather than the old tlv+frame formula.
/// MUST stay in sync with AppConstants.Protocol.MAX_PAYLOAD_LENGTH in the Android repo (issue #1618).
public static let maxFramedFileBytes: Int = 10_485_760

View File

@ -354,7 +354,7 @@ struct BinaryProtocolTests {
func payloadSizeBetweenOldAndNewLimit() throws {
let payloadSize = 2_000_000
let payload = Data(repeating: 0x41, count: payloadSize)
let packet = TestHelpers.createTestPacket(payload: payload)
let packet = TestHelpers.createTestPacket(payload: payload, version: 2)
let encodedData = try #require(BinaryProtocol.encode(packet), "Failed to encode packet")
let decodedPacket = try #require(BinaryProtocol.decode(encodedData), "Failed to decode packet")

View File

@ -56,7 +56,8 @@ final class TestHelpers {
recipientID: PeerID? = nil,
payload: Data = Data("test payload".utf8),
signature: Data? = nil,
ttl: UInt8 = 3
ttl: UInt8 = 3,
version: UInt8 = 1
) -> BitchatPacket {
return BitchatPacket(
type: type,
@ -65,7 +66,8 @@ final class TestHelpers {
timestamp: UInt64(Date().timeIntervalSince1970 * 1000),
payload: payload,
signature: signature,
ttl: ttl
ttl: ttl,
version: version
)
}