damus

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

MockDamusState.swift (2233B)


      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 
     11 // Generates a test damus state with configurable mock parameters
     12 func generate_test_damus_state(
     13     mock_profile_info: [Pubkey: Profile]?
     14 ) -> DamusState {
     15     // Create a unique temporary directory
     16     let ndb = Ndb.test
     17     let our_pubkey = test_pubkey
     18     let pool = RelayPool(ndb: ndb)
     19     let settings = UserSettingsStore()
     20     
     21     let profiles: Profiles = {
     22         guard let mock_profile_info, let profiles: Profiles = MockProfiles(mocked_profiles: mock_profile_info, ndb: ndb) else {
     23             return Profiles.init(ndb: ndb)
     24         }
     25         return profiles
     26     }()
     27     
     28     let mutelist_manager = MutelistManager(user_keypair: test_keypair)
     29     let damus = DamusState(pool: pool,
     30                            keypair: test_keypair,
     31                            likes: .init(our_pubkey: our_pubkey),
     32                            boosts: .init(our_pubkey: our_pubkey),
     33                            contacts: .init(our_pubkey: our_pubkey), mutelist_manager: mutelist_manager,
     34                            profiles: profiles,
     35                            dms: .init(our_pubkey: our_pubkey),
     36                            previews: .init(),
     37                            zaps: .init(our_pubkey: our_pubkey),
     38                            lnurls: .init(),
     39                            settings: settings,
     40                            relay_filters: .init(our_pubkey: our_pubkey),
     41                            relay_model_cache: .init(),
     42                            drafts: .init(),
     43                            events: .init(ndb: ndb),
     44                            bookmarks: .init(pubkey: our_pubkey),
     45                            postbox: .init(pool: pool),
     46                            bootstrap_relays: .init(),
     47                            replies: .init(our_pubkey: our_pubkey),
     48                            wallet: .init(settings: settings),
     49                            nav: .init(),
     50                            music: .init(onChange: {_ in }),
     51                            video: .init(),
     52                            ndb: ndb,
     53                            quote_reposts: .init(our_pubkey: our_pubkey) )
     54 
     55     return damus
     56 }