damus

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

commit dd29e871465332828ddeed59b151177166f7601e
parent c71b0ee91688f4a975000e33b5dc37a0f0e74c6d
Author: Jon Marrs <jdmarrs@gmail.com>
Date:   Wed, 30 Aug 2023 16:22:04 -0700

test: pass keypair instead of privkey for test cases

Tests were not building due to recent changes in the Damus source code that replaced privkey with keypair. This patch extends those changes to the test cases, allowing the tests to build and pass.

Signed-off-by: Jon Marrs <jdmarrs@gmail.com>
Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
MdamusTests/LongPostTests.swift | 2+-
MdamusTests/NoteContentViewTests.swift | 4++--
MdamusTests/ReplyTests.swift | 14+++++++-------
MdamusTests/damusTests.swift | 2+-
Mnostrdb/Test/NdbTests.swift | 8++++----
5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/damusTests/LongPostTests.swift b/damusTests/LongPostTests.swift @@ -34,7 +34,7 @@ final class LongPostTests: XCTestCase { XCTAssertEqual(subid, "subid") XCTAssertTrue(ev.should_show_event) XCTAssertTrue(!ev.too_big) - XCTAssertTrue(should_show_event(privkey: test_keypair.privkey, hellthreads: test_damus_state().muted_threads, contacts: contacts, ev: ev)) + XCTAssertTrue(should_show_event(keypair: test_keypair, hellthreads: test_damus_state().muted_threads, contacts: contacts, ev: ev)) XCTAssertTrue(validate_event(ev: ev) == .ok ) } diff --git a/damusTests/NoteContentViewTests.swift b/damusTests/NoteContentViewTests.swift @@ -12,7 +12,7 @@ class NoteContentViewTests: XCTestCase { func testRenderBlocksWithNonLatinHashtags() { let content = "Damusはかっこいいです #cool #かっこいい" let note = NostrEvent(content: content, keypair: test_keypair, tags: [["t", "かっこいい"]])! - let parsed: Blocks = parse_note_content(content: .init(note: note, privkey: test_keypair.privkey)) + let parsed: Blocks = parse_note_content(content: .init(note: note, keypair: test_keypair)) let testState = test_damus_state() @@ -31,7 +31,7 @@ class NoteContentViewTests: XCTestCase { func testParseImageBlockInContentWithEscapedSlashes() { let testJSONWithEscapedSlashes = "{\"tags\":[],\"pubkey\":\"f8e6c64342f1e052480630e27e1016dce35fc3a614e60434fef4aa2503328ca9\",\"content\":\"https:\\/\\/cdn.nostr.build\\/i\\/5c1d3296f66c2630131bf123106486aeaf051ed8466031c0e0532d70b33cddb2.jpg\",\"created_at\":1691864981,\"kind\":1,\"sig\":\"fc0033aa3d4df50b692a5b346fa816fdded698de2045e36e0642a021391468c44ca69c2471adc7e92088131872d4aaa1e90ea6e1ad97f3cc748f4aed96dfae18\",\"id\":\"e8f6eca3b161abba034dac9a02bb6930ecde9fd2fb5d6c5f22a05526e11382cb\"}" let testNote = NostrEvent.owned_from_json(json: testJSONWithEscapedSlashes)! - let parsed = parse_note_content(content: .init(note: testNote, privkey: test_keypair.privkey)) + let parsed = parse_note_content(content: .init(note: testNote, keypair: test_keypair)) XCTAssertTrue((parsed.blocks[0].is_url != nil), "NoteContentView does not correctly parse an image block when url in JSON content contains optional escaped slashes.") } diff --git a/damusTests/ReplyTests.swift b/damusTests/ReplyTests.swift @@ -23,7 +23,7 @@ class ReplyTests: XCTestCase { let content = "this is #[0] a mention" let tags = [evid.tag] let ev = NostrEvent(content: content, keypair: test_keypair, tags: tags)! - let blocks = parse_note_content(content: .init(note: ev, privkey: test_keypair.privkey)).blocks + let blocks = parse_note_content(content: .init(note: ev, keypair: test_keypair)).blocks let event_refs = interpret_event_refs(blocks: blocks, tags: ev.tags) XCTAssertEqual(event_refs.count, 1) @@ -76,7 +76,7 @@ class ReplyTests: XCTestCase { let mentioned_id = NoteId(hex: "5a534797e8cd3b9f4c1cf63e20e48bd0e8bd7f8c4d6353fbd576df000f6f54d3")! let tags = [thread_id.tag, mentioned_id.tag] let ev = NostrEvent(content: content, keypair: test_keypair, tags: tags)! - let blocks = parse_note_content(content: .init(note: ev, privkey: test_keypair.privkey)).blocks + let blocks = parse_note_content(content: .init(note: ev, keypair: test_keypair)).blocks let event_refs = interpret_event_refs(blocks: blocks, tags: ev.tags) XCTAssertEqual(event_refs.count, 2) @@ -93,7 +93,7 @@ class ReplyTests: XCTestCase { func testEmptyMention() throws { let content = "this is some & content" let ev = NostrEvent(content: content, keypair: test_keypair, tags: [])! - let blocks = parse_note_content(content: .init(note: ev, privkey: test_keypair.privkey)).blocks + let blocks = parse_note_content(content: .init(note: ev, keypair: test_keypair)).blocks let post_blocks = parse_post_blocks(content: content) let post_tags = make_post_tags(post_blocks: post_blocks, tags: []) let event_refs = interpret_event_refs(blocks: blocks, tags: ev.tags) @@ -108,7 +108,7 @@ class ReplyTests: XCTestCase { let content = "#[10]" let tags: [[String]] = [[],[],[],[],[],[],[],[],[],[],["p", "3e999f94e2cb34ef44a64b351141ac4e51b5121b2d31aed4a6c84602a1144692"]] let ev = NostrEvent(content: content, keypair: test_keypair, tags: tags)! - let blocks = parse_note_content(content: .init(note: ev, privkey: test_keypair.privkey)).blocks + let blocks = parse_note_content(content: .init(note: ev, keypair: test_keypair)).blocks let mentions = blocks.filter { $0.is_mention != nil } XCTAssertEqual(mentions.count, 1) } @@ -145,7 +145,7 @@ class ReplyTests: XCTestCase { let reply_id = NoteId(hex: "80093e9bdb495728f54cda2bad4aed096877189552b3d41264e73b9a9595be22")! let tags = [thread_id.tag, reply_id.tag] let ev = NostrEvent(content: content, keypair: test_keypair, tags: tags)! - let blocks = parse_note_content(content: .init(note: ev, privkey: test_keypair.privkey)).blocks + let blocks = parse_note_content(content: .init(note: ev, keypair: test_keypair)).blocks let event_refs = interpret_event_refs(blocks: blocks, tags: ev.tags) XCTAssertEqual(event_refs.count, 2) @@ -265,7 +265,7 @@ class ReplyTests: XCTestCase { func testNoReply() throws { let content = "this is a #[0] reply" let ev = NostrEvent(content: content, keypair: test_keypair, tags: [])! - let blocks = parse_note_content(content: .init(note: ev, privkey: test_keypair.privkey)).blocks + let blocks = parse_note_content(content: .init(note: ev, keypair: test_keypair)).blocks let event_refs = interpret_event_refs(blocks: blocks, tags:ev.tags) XCTAssertEqual(event_refs.count, 0) @@ -275,7 +275,7 @@ class ReplyTests: XCTestCase { let note_id = NoteId(hex: "53f60f5114c06f069ffe9da2bc033e533d09cae44d37a8462154a663771a4ce6")! let tags = [note_id.tag] let ev = NostrEvent(content: "this is #[0] a mention", keypair: test_keypair, tags: tags)! - let parsed = parse_note_content(content: .init(note: ev, privkey: test_keypair.privkey)).blocks + let parsed = parse_note_content(content: .init(note: ev, keypair: test_keypair)).blocks XCTAssertNotNil(parsed) XCTAssertEqual(parsed.count, 3) diff --git a/damusTests/damusTests.swift b/damusTests/damusTests.swift @@ -190,7 +190,7 @@ class damusTests: XCTestCase { func testParseMentionOnlyText() { let tags = [["e", "event_id"]] let ev = NostrEvent(content: "there is no mention here", keypair: test_keypair, tags: tags)! - let parsed = parse_note_content(content: .init(note: ev, privkey: test_keypair.privkey)).blocks + let parsed = parse_note_content(content: .init(note: ev, keypair: test_keypair)).blocks XCTAssertNotNil(parsed) XCTAssertEqual(parsed.count, 1) diff --git a/nostrdb/Test/NdbTests.swift b/nostrdb/Test/NdbTests.swift @@ -150,7 +150,7 @@ final class NdbTests: XCTestCase { return } self.measure(options: longer_iter()) { - let blocks = event.blocks(nil).blocks + let blocks = event.blocks(test_keypair).blocks let xs = interpret_event_refs(blocks: blocks, tags: event.tags) XCTAssertEqual(xs.count, 1) } @@ -161,7 +161,7 @@ final class NdbTests: XCTestCase { return } self.measure(options: longer_iter()) { - let blocks = note.blocks(nil).blocks + let blocks = note.blocks(test_keypair).blocks let xs = interpret_event_refs_ndb(blocks: blocks, tags: note.tags) XCTAssertEqual(xs.count, 1) } @@ -180,8 +180,8 @@ final class NdbTests: XCTestCase { XCTAssertEqual(note.pubkey, event.pubkey) XCTAssertEqual(note.id, event.id) - let ev_blocks = event.blocks(nil) - let note_blocks = note.blocks(nil) + let ev_blocks = event.blocks(test_keypair) + let note_blocks = note.blocks(test_keypair) XCTAssertEqual(ev_blocks, note_blocks)