This implements some useful functions to use negentropy from RelayPool, but does not integrate them with the rest of the app. No changelog for the negentropy support right now as it is not hooked up to any user-facing feature Changelog-Fixed: Fixed a race condition in the networking logic that could cause notes to get missed in certain rare scenarios Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
52 lines
1.3 KiB
Swift
52 lines
1.3 KiB
Swift
//
|
|
// LargeEventTests.swift
|
|
// damusTests
|
|
//
|
|
// Created by William Casarin on 2023-08-05.
|
|
//
|
|
|
|
import XCTest
|
|
@testable import damus
|
|
|
|
final class LargeEventTests: XCTestCase {
|
|
|
|
func testLongPost() async throws {
|
|
let json = "[\"EVENT\",\"subid\",\(test_failing_nostr_report)]"
|
|
let resp = NostrResponse.decode(from: json)
|
|
|
|
XCTAssertNotNil(resp)
|
|
guard let resp,
|
|
case .event(let subid, let ev) = resp
|
|
else {
|
|
XCTAssertFalse(true)
|
|
return
|
|
}
|
|
|
|
XCTAssertEqual(subid, "subid")
|
|
XCTAssertTrue(ev.should_show_event)
|
|
XCTAssertTrue(!ev.too_big)
|
|
let shouldShowEvent = await should_show_event(state: test_damus_state, ev: ev)
|
|
XCTAssertTrue(shouldShowEvent)
|
|
XCTAssertTrue(validate_event(ev: ev) == .ok)
|
|
}
|
|
|
|
func testIsHellthread() throws {
|
|
let json = "[\"EVENT\",\"subid\",\(test_failing_nostr_report)]"
|
|
let resp = NostrResponse.decode(from: json)
|
|
|
|
XCTAssertNotNil(resp)
|
|
guard let resp,
|
|
case .event(let subid, let ev) = resp
|
|
else {
|
|
XCTAssertFalse(true)
|
|
return
|
|
}
|
|
|
|
XCTAssertEqual(subid, "subid")
|
|
XCTAssertTrue(ev.should_show_event)
|
|
XCTAssertTrue(ev.is_hellthread(max_pubkeys: 10))
|
|
XCTAssertTrue(validate_event(ev: ev) == .ok)
|
|
}
|
|
|
|
}
|