damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

MockDamusState.swift (2347B)


      1 //
      2 //  MockDamusState.swift
      3 //  damusTests
      4 //
      5 //  Created by Daniel D’Aquino on 2023-10-13.
      6 //
      7 
      8 import Foundation
      9 @testable import damus
     10 import EmojiPicker
     11 
     12 // Generates a test damus state with configurable mock parameters
     13 func generate_test_damus_state(
     14     mock_profile_info: [Pubkey: Profile]?
     15 ) -> DamusState {
     16     // Create a unique temporary directory
     17     let ndb = Ndb.test
     18     let our_pubkey = test_pubkey
     19     let pool = RelayPool(ndb: ndb)
     20     let settings = UserSettingsStore()
     21     
     22     let profiles: Profiles = {
     23         guard let mock_profile_info, let profiles: Profiles = MockProfiles(mocked_profiles: mock_profile_info, ndb: ndb) else {
     24             return Profiles.init(ndb: ndb)
     25         }
     26         return profiles
     27     }()
     28     
     29     let mutelist_manager = MutelistManager(user_keypair: test_keypair)
     30     let damus = DamusState(pool: pool,
     31                            keypair: test_keypair,
     32                            likes: .init(our_pubkey: our_pubkey),
     33                            boosts: .init(our_pubkey: our_pubkey),
     34                            contacts: .init(our_pubkey: our_pubkey), mutelist_manager: mutelist_manager,
     35                            profiles: profiles,
     36                            dms: .init(our_pubkey: our_pubkey),
     37                            previews: .init(),
     38                            zaps: .init(our_pubkey: our_pubkey),
     39                            lnurls: .init(),
     40                            settings: settings,
     41                            relay_filters: .init(our_pubkey: our_pubkey),
     42                            relay_model_cache: .init(),
     43                            drafts: .init(),
     44                            events: .init(ndb: ndb),
     45                            bookmarks: .init(pubkey: our_pubkey),
     46                            postbox: .init(pool: pool),
     47                            bootstrap_relays: .init(),
     48                            replies: .init(our_pubkey: our_pubkey),
     49                            wallet: .init(settings: settings),
     50                            nav: .init(),
     51                            music: .init(onChange: {_ in }),
     52                            video: .init(),
     53                            ndb: ndb,
     54                            quote_reposts: .init(our_pubkey: our_pubkey),
     55                            emoji_provider: DefaultEmojiProvider(showAllVariations: false)
     56     )
     57 
     58     return damus
     59 }