Fix private media Noise round-trip fixture

This commit is contained in:
jack
2026-07-25 17:18:40 +02:00
parent 758d759e32
commit 7a374579b7
@@ -308,9 +308,9 @@ struct NoiseEncryptionServiceTests {
func largePrivateFileNoiseRoundTrip() throws { func largePrivateFileNoiseRoundTrip() throws {
let alice = NoiseEncryptionService(keychain: MockKeychain()) let alice = NoiseEncryptionService(keychain: MockKeychain())
let bob = NoiseEncryptionService(keychain: MockKeychain()) let bob = NoiseEncryptionService(keychain: MockKeychain())
let alicePeerID = PeerID(str: "0011223344556677") let alicePeerID = PeerID(publicKey: alice.getStaticPublicKeyData())
let bobPeerID = PeerID(str: "8899aabbccddeeff") let bobPeerID = PeerID(publicKey: bob.getStaticPublicKeyData())
try establishSessions(alice: alice, bob: bob, alicePeerID: alicePeerID, bobPeerID: bobPeerID) try establishSessions(alice: alice, bob: bob)
let content = Data("%PDF-1.7\n".utf8) + Data(repeating: 0x51, count: 96 * 1024) let content = Data("%PDF-1.7\n".utf8) + Data(repeating: 0x51, count: 96 * 1024)
let file = BitchatFilePacket( let file = BitchatFilePacket(
@@ -328,7 +328,7 @@ struct NoiseEncryptionServiceTests {
) )
do { do {
_ = try alice.encrypt(typedPayload, for: alicePeerID) _ = try alice.encrypt(typedPayload, for: bobPeerID)
Issue.record("Ordinary Noise payload path must retain its 64 KiB ceiling") Issue.record("Ordinary Noise payload path must retain its 64 KiB ceiling")
} catch NoiseSecurityError.messageTooLarge { } catch NoiseSecurityError.messageTooLarge {
// Expected: only the purpose-specific private-file API may extend it. // Expected: only the purpose-specific private-file API may extend it.
@@ -336,14 +336,14 @@ struct NoiseEncryptionServiceTests {
let ciphertext: Data let ciphertext: Data
do { do {
ciphertext = try alice.encryptPrivateFilePayload(typedPayload, for: alicePeerID) ciphertext = try alice.encryptPrivateFilePayload(typedPayload, for: bobPeerID)
} catch { } catch {
Issue.record("Private-file encryption failed: \(error)") Issue.record("Private-file encryption failed: \(error)")
return return
} }
let decrypted: Data let decrypted: Data
do { do {
decrypted = try bob.decrypt(ciphertext, from: bobPeerID) decrypted = try bob.decrypt(ciphertext, from: alicePeerID)
} catch { } catch {
Issue.record("Private-file decryption failed: \(error); ciphertextBytes=\(ciphertext.count)") Issue.record("Private-file decryption failed: \(error); ciphertextBytes=\(ciphertext.count)")
return return