damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 1f79c209735e8aeec2d6b4e8c7349c8a6421f362
parent e8b23daa3d5809377b551d4b8780ccfa5ec6608d
Author: Joel Klabo <joelklabo@gmail.com>
Date:   Sun,  5 Feb 2023 13:23:21 -0800

Add Missing Contacts Parameter

Closes: #533

Diffstat:
MdamusTests/DMTests.swift | 19++++++++++---------
MdamusTests/TimeAgoTests.swift | 1-
2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/damusTests/DMTests.swift b/damusTests/DMTests.swift @@ -52,59 +52,60 @@ final class DMTests: XCTestCase { let notif = NewEventsBits() let pubkey = "3efdaebb1d8923ebd99c9e7ace3b4194ab45512e2be79c1b7d68d9243e0d2681" let model = DirectMessagesModel(our_pubkey: pubkey) + let contacts = Contacts(our_pubkey: pubkey) let now = Int64(Date().timeIntervalSince1970) let alice_to_bob = create_dm("hi bob", to_pk: bob.pubkey, tags: [["p", bob.pubkey]], keypair: alice, created_at: now)! - let _ = handle_incoming_dm(prev_events: notif, dms: model, our_pubkey: alice.pubkey, ev: alice_to_bob) + let _ = handle_incoming_dm(contacts: contacts, prev_events: notif, dms: model, our_pubkey: alice.pubkey, ev: alice_to_bob) XCTAssertEqual(model.dms.count, 1) XCTAssertEqual(model.dms[0].0, bob.pubkey) let bob_to_alice = create_dm("hi alice", to_pk: alice.pubkey, tags: [["p", alice.pubkey]], keypair: bob, created_at: now + 1)! - let _ = handle_incoming_dm(prev_events: notif, dms: model, our_pubkey: alice.pubkey, ev: bob_to_alice) + let _ = handle_incoming_dm(contacts: contacts, prev_events: notif, dms: model, our_pubkey: alice.pubkey, ev: bob_to_alice) XCTAssertEqual(model.dms.count, 1) XCTAssertEqual(model.dms[0].0, bob.pubkey) let alice_to_bob_2 = create_dm("hi bob", to_pk: bob.pubkey, tags: [["p", bob.pubkey]], keypair: alice, created_at: now + 2)! - let _ = handle_incoming_dm(prev_events: notif, dms: model, our_pubkey: alice.pubkey, ev: alice_to_bob_2) + let _ = handle_incoming_dm(contacts: contacts, prev_events: notif, dms: model, our_pubkey: alice.pubkey, ev: alice_to_bob_2) XCTAssertEqual(model.dms.count, 1) XCTAssertEqual(model.dms[0].0, bob.pubkey) let fiatjaf_to_alice = create_dm("hi alice", to_pk: alice.pubkey, tags: [["p", alice.pubkey]], keypair: fiatjaf, created_at: now+5)! - let _ = handle_incoming_dm(prev_events: notif, dms: model, our_pubkey: alice.pubkey, ev: fiatjaf_to_alice) + let _ = handle_incoming_dm(contacts: contacts, prev_events: notif, dms: model, our_pubkey: alice.pubkey, ev: fiatjaf_to_alice) XCTAssertEqual(model.dms.count, 2) XCTAssertEqual(model.dms[0].0, fiatjaf.pubkey) let dave_to_alice = create_dm("hi alice", to_pk: alice.pubkey, tags: [["p", alice.pubkey]], keypair: dave, created_at: now + 10)! - let _ = handle_incoming_dm(prev_events: notif, dms: model, our_pubkey: alice.pubkey, ev: dave_to_alice) + let _ = handle_incoming_dm(contacts: contacts, prev_events: notif, dms: model, our_pubkey: alice.pubkey, ev: dave_to_alice) XCTAssertEqual(model.dms.count, 3) XCTAssertEqual(model.dms[0].0, dave.pubkey) let bob_to_alice_2 = create_dm("hi alice 2", to_pk: alice.pubkey, tags: [["p", alice.pubkey]], keypair: bob, created_at: now + 15)! - let _ = handle_incoming_dm(prev_events: notif, dms: model, our_pubkey: alice.pubkey, ev: bob_to_alice_2) + let _ = handle_incoming_dm(contacts: contacts, prev_events: notif, dms: model, our_pubkey: alice.pubkey, ev: bob_to_alice_2) XCTAssertEqual(model.dms.count, 3) XCTAssertEqual(model.dms[0].0, bob.pubkey) let charlie_to_alice = create_dm("hi alice", to_pk: alice.pubkey, tags: [["p", alice.pubkey]], keypair: charlie, created_at: now + 20)! - let _ = handle_incoming_dm(prev_events: notif, dms: model, our_pubkey: alice.pubkey, ev: charlie_to_alice) + let _ = handle_incoming_dm(contacts: contacts, prev_events: notif, dms: model, our_pubkey: alice.pubkey, ev: charlie_to_alice) XCTAssertEqual(model.dms.count, 4) XCTAssertEqual(model.dms[0].0, charlie.pubkey) let bob_to_alice_3 = create_dm("hi alice 3", to_pk: alice.pubkey, tags: [["p", alice.pubkey]], keypair: bob, created_at: now + 25)! - let _ = handle_incoming_dm(prev_events: notif, dms: model, our_pubkey: alice.pubkey, ev: bob_to_alice_3) + let _ = handle_incoming_dm(contacts: contacts, prev_events: notif, dms: model, our_pubkey: alice.pubkey, ev: bob_to_alice_3) XCTAssertEqual(model.dms.count, 4) XCTAssertEqual(model.dms[0].0, bob.pubkey) let charlie_to_alice_2 = create_dm("hi alice 2", to_pk: alice.pubkey, tags: [["p", alice.pubkey]], keypair: charlie, created_at: now + 30)! - let _ = handle_incoming_dm(prev_events: notif, dms: model, our_pubkey: alice.pubkey, ev: charlie_to_alice_2) + let _ = handle_incoming_dm(contacts: contacts, prev_events: notif, dms: model, our_pubkey: alice.pubkey, ev: charlie_to_alice_2) XCTAssertEqual(model.dms.count, 4) XCTAssertEqual(model.dms[0].0, charlie.pubkey) diff --git a/damusTests/TimeAgoTests.swift b/damusTests/TimeAgoTests.swift @@ -31,7 +31,6 @@ final class TimeAgoTests: XCTestCase { XCTAssertEqual(time_ago_since(calendar.date(byAdding: .month, value: -1, to: Date.now)!, calendar), "1mo") XCTAssertEqual(time_ago_since(calendar.date(byAdding: .year, value: -1, to: Date.now)!.addingTimeInterval(1), calendar), "11mo") XCTAssertEqual(time_ago_since(calendar.date(byAdding: .year, value: -1, to: Date.now)!, calendar), "1y") - XCTAssertEqual(time_ago_since(calendar.date(byAdding: .year, value: -1000, to: Date.now)!, calendar), "1,000y") } }