Expand Nostr and identity coverage (#1059)

Co-authored-by: jack <jackjackbits@users.noreply.github.com>
This commit is contained in:
jack
2026-03-12 19:41:05 -10:00
committed by GitHub
co-authored by jack
parent 264a95b61a
commit 7d83310bc2
12 changed files with 1627 additions and 161 deletions
+14 -2
View File
@@ -215,7 +215,7 @@ struct NostrProtocolTests {
@Test func nostrEventSignatureVerification_roundTrip() throws {
let identity = try NostrIdentity.generate()
var event = NostrEvent(
let event = NostrEvent(
pubkey: identity.publicKeyHex,
createdAt: Date(),
kind: .ephemeralEvent,
@@ -228,7 +228,7 @@ struct NostrProtocolTests {
@Test func nostrEventSignatureVerification_detectsTamper() throws {
let identity = try NostrIdentity.generate()
var event = NostrEvent(
let event = NostrEvent(
pubkey: identity.publicKeyHex,
createdAt: Date(),
kind: .ephemeralEvent,
@@ -240,6 +240,18 @@ struct NostrProtocolTests {
#expect(!signed.isValidSignature())
}
@Test func geohashNotesSingleFilter_encodesExpectedTagShape() throws {
let since = Date(timeIntervalSince1970: 1_234_567)
let filter = NostrFilter.geohashNotes("u4pruyd", since: since, limit: 42)
let data = try JSONEncoder().encode(filter)
let object = try #require(try JSONSerialization.jsonObject(with: data) as? [String: Any])
#expect(object["kinds"] as? [Int] == [1])
#expect(object["#g"] as? [String] == ["u4pruyd"])
#expect(object["since"] as? Int == 1_234_567)
#expect(object["limit"] as? Int == 42)
}
// MARK: - Helpers
private static func base64URLDecode(_ s: String) -> Data? {
var str = s.replacingOccurrences(of: "-", with: "+").replacingOccurrences(of: "_", with: "/")