mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 01:45:20 +00:00
Tests: gate verbose prints under DEBUG; ChatViewModel: remove legacy fingerprint helper and rely on UnifiedPeerService
This commit is contained in:
@@ -3617,26 +3617,8 @@ class ChatViewModel: ObservableObject, BitchatDelegate {
|
||||
return unifiedPeerService.getFingerprint(for: peerID)
|
||||
}
|
||||
|
||||
private func getFingerprint_old(for peerID: String) -> String? {
|
||||
// Remove debug logging to prevent console spam during view updates
|
||||
|
||||
// First try to get fingerprint from mesh service's peer ID rotation mapping
|
||||
if let fingerprint = meshService.getFingerprint(for: peerID) {
|
||||
return fingerprint
|
||||
}
|
||||
|
||||
// Check noise service (direct Noise session fingerprint)
|
||||
if let fingerprint = meshService.getNoiseService().getPeerFingerprint(peerID) {
|
||||
return fingerprint
|
||||
}
|
||||
|
||||
// Last resort: check local mapping
|
||||
if let fingerprint = peerIDToPublicKeyFingerprint[peerID] {
|
||||
return fingerprint
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
// (legacy getFingerprint_old removed; UnifiedPeerService is the source of truth)
|
||||
|
||||
|
||||
// Helper to resolve nickname for a peer ID through various sources
|
||||
@MainActor
|
||||
|
||||
@@ -21,8 +21,10 @@ final class NostrProtocolTests: XCTestCase {
|
||||
let sender = try NostrIdentity.generate()
|
||||
let recipient = try NostrIdentity.generate()
|
||||
|
||||
#if DEBUG
|
||||
print("Sender pubkey: \(sender.publicKeyHex)")
|
||||
print("Recipient pubkey: \(recipient.publicKeyHex)")
|
||||
#endif
|
||||
|
||||
// Create a test message
|
||||
let originalContent = "Hello from NIP-17 test!"
|
||||
@@ -34,8 +36,10 @@ final class NostrProtocolTests: XCTestCase {
|
||||
senderIdentity: sender
|
||||
)
|
||||
|
||||
#if DEBUG
|
||||
print("Gift wrap created with ID: \(giftWrap.id)")
|
||||
print("Gift wrap pubkey: \(giftWrap.pubkey)")
|
||||
#endif
|
||||
|
||||
// Decrypt the gift wrap
|
||||
let (decryptedContent, senderPubkey, timestamp) = try NostrProtocol.decryptPrivateMessage(
|
||||
@@ -52,7 +56,9 @@ final class NostrProtocolTests: XCTestCase {
|
||||
let timeDiff = abs(messageDate.timeIntervalSinceNow)
|
||||
XCTAssertLessThan(timeDiff, 60, "Message timestamp should be recent")
|
||||
|
||||
#if DEBUG
|
||||
print("✅ Successfully decrypted message: '\(decryptedContent)' from \(senderPubkey) at \(messageDate)")
|
||||
#endif
|
||||
}
|
||||
|
||||
func testGiftWrapUsesUniqueEphemeralKeys() throws {
|
||||
@@ -75,8 +81,10 @@ final class NostrProtocolTests: XCTestCase {
|
||||
|
||||
// Gift wrap pubkeys should be different (unique ephemeral keys)
|
||||
XCTAssertNotEqual(message1.pubkey, message2.pubkey)
|
||||
#if DEBUG
|
||||
print("Message 1 gift wrap pubkey: \(message1.pubkey)")
|
||||
print("Message 2 gift wrap pubkey: \(message2.pubkey)")
|
||||
#endif
|
||||
|
||||
// Both should decrypt successfully
|
||||
let (content1, _, _) = try NostrProtocol.decryptPrivateMessage(
|
||||
@@ -109,7 +117,9 @@ final class NostrProtocolTests: XCTestCase {
|
||||
giftWrap: giftWrap,
|
||||
recipientIdentity: wrongRecipient
|
||||
)) { error in
|
||||
#if DEBUG
|
||||
print("Expected error when decrypting with wrong key: \(error)")
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user