Files
damus/damusTests/MutingTests.swift
Daniel D’Aquino 71c36052e2 Fix onboarding crash
This commit fixes a crash that occurred when clicking "follow all"
during onboarding.

This fix works by making `Contacts` and `PostBox` isolated into a
specific Swift Actor, and updating direct and indirect usages
accordingly.

Changelog-Fixed: Fixed a crash that occurred when clicking "follow all" during onboarding.
Closes: https://github.com/damus-io/damus/issues/3422
Co-authored-by: alltheseas <64376233+alltheseas@users.noreply.github.com>
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
2026-01-05 17:28:06 -08:00

47 lines
1.9 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//
// MutingTests.swift
// damusTests
//
// Created by Daniel DAquino on 2024-05-06.
//
import Foundation
import XCTest
@testable import damus
final class MutingTests: XCTestCase {
@MainActor
func testWordMuting() async {
// Setup some test data
let test_note = NostrEvent(
content: "Nostr is the super app. Because its actually an ecosystem of apps, all of which make each other better. People havent grasped that yet. They will when its more accessible and onboarding is more straightforward and intuitive.",
keypair: jack_keypair,
createdAt: UInt32(Date().timeIntervalSince1970 - 100)
)!
let spammy_keypair = generate_new_keypair().to_keypair()
let spammy_test_note = NostrEvent(
content: "Some spammy airdrop just arrived! Why stack sats when you can get scammed instead with some random coin? Call 1-800-GET-SCAMMED to claim your airdrop today!",
keypair: spammy_keypair,
createdAt: UInt32(Date().timeIntervalSince1970 - 100)
)!
let mute_item: MuteItem = .word("airdrop", nil)
let existing_mutelist = await test_damus_state.mutelist_manager.event
guard
let full_keypair = test_damus_state.keypair.to_full(),
let mutelist = create_or_update_mutelist(keypair: full_keypair, mprev: existing_mutelist, to_add: mute_item)
else {
return
}
await test_damus_state.mutelist_manager.set_mutelist(mutelist)
await test_damus_state.nostrNetwork.postbox.send(mutelist)
let spammy_note_muted = await test_damus_state.mutelist_manager.is_event_muted(spammy_test_note)
XCTAssert(spammy_note_muted)
let test_note_muted = await test_damus_state.mutelist_manager.is_event_muted(test_note)
XCTAssertFalse(test_note_muted)
}
}