nostrdb: initial Ndb class

This commit is contained in:
William Casarin
2023-08-25 18:13:42 -07:00
parent 1f5f1e28a4
commit 35b67dc08d
4 changed files with 78 additions and 1 deletions

View File

@@ -31,6 +31,29 @@ final class NdbTests: XCTestCase {
}
func test_ndb_init() {
do {
let ndb = Ndb()!
let ok = ndb.process_events(test_wire_events)
XCTAssertTrue(ok)
}
do {
let ndb = Ndb()!
let id1 = NoteId(hex: "d12c17bde3094ad32f4ab862a6cc6f5c289cfe7d5802270bdf34904df585f349")!
let note1 = ndb.lookup_note(id1)
XCTAssertNotNil(note1)
let id = NoteId(hex: "b2e03951843b191b5d9d1969f48db0156b83cc7dbd841f543f109362e24c4a9c")!
let note = ndb.lookup_note(id)
XCTAssertNotNil(note)
guard let note else { return }
XCTAssertEqual(note.pubkey, Pubkey(hex: "32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245")!)
}
}
func test_ndb_note() throws {
let note = NdbNote.owned_from_json(json: test_contact_list_json)
XCTAssertNotNil(note)