Mock create account function

pull/2/head
Michael Scoff 7 years ago
parent f2f638c143
commit e7407a8021
  1. 3
      Trust/EtherClient/Keystore.swift
  2. 5
      TrustTests/Factories/FakeEtherKeystore.swift
  3. 5
      TrustTests/Factories/FakeKeystore.swift

@ -1,9 +1,12 @@
// Copyright SIX DAY LLC. All rights reserved.
import Foundation
import Result
protocol Keystore {
var hasAccounts: Bool { get }
var accounts: [Account] { get }
var recentlyUsedAccount: Account? { get set }
func createAccount(with password: String, completion: @escaping (Result<Account, KeyStoreError>) -> Void)
}

@ -3,6 +3,7 @@
import Foundation
@testable import Trust
import KeychainSwift
import Result
class FakeEtherKeystore: EtherKeystore {
convenience init() {
@ -12,4 +13,8 @@ class FakeEtherKeystore: EtherKeystore {
keyStoreSubfolder: "/" + uniqueString
)
}
override func createAccount(with password: String, completion: @escaping (Result<Account, KeyStoreError>) -> Void) {
completion(.success(.make()))
}
}

@ -2,6 +2,7 @@
import Foundation
@testable import Trust
import Result
struct FakeKeystore: Keystore {
var hasAccounts: Bool {
@ -17,6 +18,10 @@ struct FakeKeystore: Keystore {
self.accounts = accounts
self.recentlyUsedAccount = recentlyUsedAccount
}
func createAccount(with password: String, completion: @escaping (Result<Account, KeyStoreError>) -> Void) {
completion(.success(.make()))
}
}
extension FakeKeystore {

Loading…
Cancel
Save