mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 22:25:20 +00:00
Expand Nostr and identity coverage (#1059)
Co-authored-by: jack <jackjackbits@users.noreply.github.com>
This commit is contained in:
@@ -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: "/")
|
||||
|
||||
Reference in New Issue
Block a user