pull/3154/head
Vladyslav shepitko 3 years ago
parent ca57820b3c
commit 82fa2b3a6b
  1. 10
      AlphaWallet/Market/Coordinators/UniversalLinkCoordinator.swift
  2. 21
      AlphaWalletTests/Coordinators/AppCoordinatorTests.swift
  3. 3
      AlphaWalletTests/Factories/FakeKeystore.swift
  4. 2
      AlphaWalletTests/Factories/FakeTokensDataStore.swift
  5. 8
      AlphaWalletTests/Settings/Coordinators/SettingsCoordinatorTests.swift

@ -498,6 +498,9 @@ class UniversalLinkCoordinator: Coordinator {
}
return filteredTokens
}
private lazy var tokenProvider: TokenProviderType = {
return TokenProvider(account: tokensDatastore.account, server: tokensDatastore.server)
}()
private func makeTokenHolder(_ bytes32Tokens: [String], _ contractAddress: AlphaWallet.Address) {
assetDefinitionStore.fetchXML(forContract: contractAddress, useCacheAndFetch: true) { [weak self] _ in
@ -509,7 +512,6 @@ class UniversalLinkCoordinator: Coordinator {
}
let tokensDatastore = strongSelf.tokensDatastore
let tokenProvider: TokenProviderType = TokenProvider(account: tokensDatastore.account, server: tokensDatastore.server)
if let existingToken = tokensDatastore.token(forContract: contractAddress) {
let name = XMLHandler(token: existingToken, assetDefinitionStore: strongSelf.assetDefinitionStore).getLabel(fallback: existingToken.name)
makeTokenHolder(name: name, symbol: existingToken.symbol)
@ -517,9 +519,9 @@ class UniversalLinkCoordinator: Coordinator {
let localizedTokenTypeName = R.string.localizable.tokensTitlecase()
makeTokenHolder(name: localizedTokenTypeName, symbol: "")
let getContractName = tokenProvider.getContractName(for: contractAddress)
let getContractSymbol = tokenProvider.getContractSymbol(for: contractAddress)
let getTokenType = tokenProvider.getTokenType(for: contractAddress)
let getContractName = strongSelf.tokenProvider.getContractName(for: contractAddress)
let getContractSymbol = strongSelf.tokenProvider.getContractSymbol(for: contractAddress)
let getTokenType = strongSelf.tokenProvider.getTokenType(for: contractAddress)
firstly {
when(fulfilled: getContractName, getContractSymbol, getTokenType)
}.done { name, symbol, type in

@ -27,7 +27,8 @@ class AppCoordinatorTests: XCTestCase {
window: UIWindow(),
analyticsService: FakeAnalyticsService(),
keystore: FakeKeystore(
wallets: [.make()]
wallets: [.make()],
recentlyUsedWallet: .make()
),
navigationController: FakeNavigationController()
)
@ -49,7 +50,8 @@ class AppCoordinatorTests: XCTestCase {
window: UIWindow(),
analyticsService: FakeAnalyticsService(),
keystore: FakeKeystore(
wallets: [.make()]
wallets: [.make()],
recentlyUsedWallet: .make()
)
)
coordinator.start()
@ -67,7 +69,8 @@ class AppCoordinatorTests: XCTestCase {
window: UIWindow(),
analyticsService: FakeAnalyticsService(),
keystore: FakeKeystore(
wallets: [.make()]
wallets: [.make()],
recentlyUsedWallet: .make()
),
navigationController: FakeNavigationController()
)
@ -85,14 +88,17 @@ class AppCoordinatorTests: XCTestCase {
let coordinator = try AppCoordinator(
window: UIWindow(),
analyticsService: FakeAnalyticsService(),
keystore: FakeKeystore(),
keystore: FakeKeystore(
wallets: [.make()],
recentlyUsedWallet: .make()
),
navigationController: FakeNavigationController()
)
coordinator.start()
coordinator.showTransactions(for: .make(), animated: true)
XCTAssertEqual(5, coordinator.coordinators.count)
XCTAssertEqual(7, coordinator.coordinators.count)
XCTAssertTrue(coordinator.navigationController.viewControllers[0] is AccountsViewController)
XCTAssertTrue(coordinator.navigationController.viewControllers[1] is UITabBarController)
} catch {
@ -105,7 +111,10 @@ class AppCoordinatorTests: XCTestCase {
let coordinator = try AppCoordinator(
window: .init(),
analyticsService: FakeAnalyticsService(),
keystore: FakeKeystore(wallets: [.make()])
keystore: FakeKeystore(
wallets: [.make()],
recentlyUsedWallet: .make()
)
)
coordinator.start()

@ -27,7 +27,7 @@ struct FakeKeystore: Keystore {
}
var wallets: [Wallet]
var recentlyUsedWallet: Wallet?
var subscribableWallets: Subscribable<Set<Wallet>> = .init(nil)
var subscribableWallets: Subscribable<Set<Wallet>>
var currentWallet: Wallet {
//Better crash now instead of populating callers with optionals
if let wallet = recentlyUsedWallet {
@ -43,6 +43,7 @@ struct FakeKeystore: Keystore {
self.wallets = wallets
self.recentlyUsedWallet = recentlyUsedWallet ?? FakeKeystore.currentWallet
self.assumeAllWalletsType = assumeAllWalletsType
self.subscribableWallets = .init(Set(wallets))
}
func verifySeedPhraseOfHdWallet(_ inputSeedPhrase: String, forAccount account: AlphaWallet.Address, context: LAContext, completion: @escaping (Result<Bool, KeystoreError>) -> Void) {

@ -10,6 +10,6 @@ class FakeTokensDataStore: TokensDataStore {
let account: Wallet = .make()
let config: Config = .make()
self.init(realm: realm, account: account, server: .main, config: config)
self.init(realm: realm, account: account, server: .main)
}
}

@ -94,4 +94,12 @@ final class FakeWalletBalanceCoordinator: WalletBalanceCoordinatorType {
func refreshEthBalance() {
}
func transactionsStorage(wallet: Wallet, server: RPCServer) -> TransactionsStorage {
FakeTransactionsStorage()
}
func tokensDatastore(wallet: Wallet, server: RPCServer) -> TokensDataStore {
FakeTokensDataStore()
}
}

Loading…
Cancel
Save