Skip to content

Commit 929bb0c

Browse files
committed
new test target has been implemented
1 parent b4c4410 commit 929bb0c

File tree

12 files changed

+549
-34
lines changed

12 files changed

+549
-34
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ iOSInjectionProject/
5151
#
5252
# Custom scripts
5353
fearless/env-vars.sh
54-
*.generated.swift
5554
Tests/Mocks/CommonMocks.swift
5655
Tests/Mocks/ModuleMocks.swift
56+
CIKeys.generated.swift
57+
R.generated.swift
5758
#
5859
# Generamba
5960
Templates/
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import XCTest
2+
import SSFChainRegistry
3+
import SSFNetwork
4+
import RobinHood
5+
import SoraFoundation
6+
@testable import fearless
7+
8+
final class ChainSyncServiceTests: XCTestCase, EventVisitorProtocol {
9+
10+
private var service: fearless.ChainSyncService?
11+
private let eventCenter = EventCenter.shared
12+
13+
private var expectation = XCTestExpectation()
14+
private var newOrUpdatedChainsCount: Int?
15+
private var removedChainsCount: Int?
16+
17+
override func setUpWithError() throws {
18+
let repositoryFacade = SubstrateDataStorageFacade.shared
19+
let chainRepositoryFactory = ChainRepositoryFactory(storageFacade: repositoryFacade)
20+
let chainRepository = chainRepositoryFactory.createRepository()
21+
22+
let syncService = SSFChainRegistry.ChainSyncService(
23+
chainsUrl: ApplicationConfig.shared.chainsSourceUrl,
24+
operationQueue: OperationQueue(),
25+
dataFetchFactory: NetworkOperationFactory()
26+
)
27+
28+
let chainSyncService = ChainSyncService(
29+
syncService: syncService,
30+
repository: AnyDataProviderRepository(chainRepository),
31+
eventCenter: EventCenter.shared,
32+
operationQueue: OperationManagerFacade.syncQueue,
33+
logger: Logger.shared,
34+
applicationHandler: ApplicationHandler()
35+
)
36+
fearless.ChainSyncService.fetchLocalData = true
37+
service = chainSyncService
38+
39+
eventCenter.add(observer: self, dispatchIn: nil)
40+
}
41+
42+
override func tearDownWithError() throws {
43+
service = nil
44+
newOrUpdatedChainsCount = nil
45+
removedChainsCount = nil
46+
}
47+
48+
func testEquatable() throws {
49+
service?.syncUp()
50+
expectation.expectedFulfillmentCount = 2
51+
wait(for: [expectation], timeout: 1)
52+
XCTAssertEqual(newOrUpdatedChainsCount, 0)
53+
XCTAssertEqual(removedChainsCount, 0)
54+
}
55+
56+
// MARK: - EventVisitorProtocol
57+
58+
func processChainSyncDidComplete(event: ChainSyncDidComplete) {
59+
newOrUpdatedChainsCount = event.newOrUpdatedChains.count
60+
removedChainsCount = event.removedChains.count
61+
expectation.fulfill()
62+
}
63+
}
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
// Generated using Sourcery 2.2.5 — https://github.com/krzysztofzablocki/Sourcery
2+
// DO NOT EDIT
3+
// swiftlint:disable all
4+
5+
import UIKit
6+
import SSFModels
7+
@testable import fearless
8+
9+
public class BalanceLocksFetchingMock: BalanceLocksFetching {
10+
public init() {}
11+
12+
//MARK: - fetchStakingLocks
13+
14+
public var fetchStakingLocksForThrowableError: Error?
15+
public var fetchStakingLocksForCallsCount = 0
16+
public var fetchStakingLocksForCalled: Bool {
17+
return fetchStakingLocksForCallsCount > 0
18+
}
19+
public var fetchStakingLocksForReceivedAccountId: AccountId?
20+
public var fetchStakingLocksForReceivedInvocations: [AccountId] = []
21+
public var fetchStakingLocksForReturnValue: StakingLocks!
22+
public var fetchStakingLocksForClosure: ((AccountId) throws -> StakingLocks)?
23+
24+
public func fetchStakingLocks(for accountId: AccountId) throws -> StakingLocks {
25+
if let error = fetchStakingLocksForThrowableError {
26+
throw error
27+
}
28+
fetchStakingLocksForCallsCount += 1
29+
fetchStakingLocksForReceivedAccountId = accountId
30+
fetchStakingLocksForReceivedInvocations.append(accountId)
31+
return try fetchStakingLocksForClosure.map({ try $0(accountId) }) ?? fetchStakingLocksForReturnValue
32+
}
33+
34+
//MARK: - fetchNominationPoolLocks
35+
36+
public var fetchNominationPoolLocksForThrowableError: Error?
37+
public var fetchNominationPoolLocksForCallsCount = 0
38+
public var fetchNominationPoolLocksForCalled: Bool {
39+
return fetchNominationPoolLocksForCallsCount > 0
40+
}
41+
public var fetchNominationPoolLocksForReceivedAccountId: AccountId?
42+
public var fetchNominationPoolLocksForReceivedInvocations: [AccountId] = []
43+
public var fetchNominationPoolLocksForReturnValue: StakingLocks!
44+
public var fetchNominationPoolLocksForClosure: ((AccountId) throws -> StakingLocks)?
45+
46+
public func fetchNominationPoolLocks(for accountId: AccountId) throws -> StakingLocks {
47+
if let error = fetchNominationPoolLocksForThrowableError {
48+
throw error
49+
}
50+
fetchNominationPoolLocksForCallsCount += 1
51+
fetchNominationPoolLocksForReceivedAccountId = accountId
52+
fetchNominationPoolLocksForReceivedInvocations.append(accountId)
53+
return try fetchNominationPoolLocksForClosure.map({ try $0(accountId) }) ?? fetchNominationPoolLocksForReturnValue
54+
}
55+
56+
//MARK: - fetchGovernanceLocks
57+
58+
public var fetchGovernanceLocksForThrowableError: Error?
59+
public var fetchGovernanceLocksForCallsCount = 0
60+
public var fetchGovernanceLocksForCalled: Bool {
61+
return fetchGovernanceLocksForCallsCount > 0
62+
}
63+
public var fetchGovernanceLocksForReceivedAccountId: AccountId?
64+
public var fetchGovernanceLocksForReceivedInvocations: [AccountId] = []
65+
public var fetchGovernanceLocksForReturnValue: Decimal!
66+
public var fetchGovernanceLocksForClosure: ((AccountId) throws -> Decimal)?
67+
68+
public func fetchGovernanceLocks(for accountId: AccountId) throws -> Decimal {
69+
if let error = fetchGovernanceLocksForThrowableError {
70+
throw error
71+
}
72+
fetchGovernanceLocksForCallsCount += 1
73+
fetchGovernanceLocksForReceivedAccountId = accountId
74+
fetchGovernanceLocksForReceivedInvocations.append(accountId)
75+
return try fetchGovernanceLocksForClosure.map({ try $0(accountId) }) ?? fetchGovernanceLocksForReturnValue
76+
}
77+
78+
//MARK: - fetchCrowdloanLocks
79+
80+
public var fetchCrowdloanLocksForThrowableError: Error?
81+
public var fetchCrowdloanLocksForCallsCount = 0
82+
public var fetchCrowdloanLocksForCalled: Bool {
83+
return fetchCrowdloanLocksForCallsCount > 0
84+
}
85+
public var fetchCrowdloanLocksForReceivedAccountId: AccountId?
86+
public var fetchCrowdloanLocksForReceivedInvocations: [AccountId] = []
87+
public var fetchCrowdloanLocksForReturnValue: Decimal!
88+
public var fetchCrowdloanLocksForClosure: ((AccountId) throws -> Decimal)?
89+
90+
public func fetchCrowdloanLocks(for accountId: AccountId) throws -> Decimal {
91+
if let error = fetchCrowdloanLocksForThrowableError {
92+
throw error
93+
}
94+
fetchCrowdloanLocksForCallsCount += 1
95+
fetchCrowdloanLocksForReceivedAccountId = accountId
96+
fetchCrowdloanLocksForReceivedInvocations.append(accountId)
97+
return try fetchCrowdloanLocksForClosure.map({ try $0(accountId) }) ?? fetchCrowdloanLocksForReturnValue
98+
}
99+
100+
//MARK: - fetchVestingLocks
101+
102+
public var fetchVestingLocksForCurrencyIdThrowableError: Error?
103+
public var fetchVestingLocksForCurrencyIdCallsCount = 0
104+
public var fetchVestingLocksForCurrencyIdCalled: Bool {
105+
return fetchVestingLocksForCurrencyIdCallsCount > 0
106+
}
107+
public var fetchVestingLocksForCurrencyIdReceivedArguments: (accountId: AccountId, currencyId: CurrencyId?)?
108+
public var fetchVestingLocksForCurrencyIdReceivedInvocations: [(accountId: AccountId, currencyId: CurrencyId?)] = []
109+
public var fetchVestingLocksForCurrencyIdReturnValue: Decimal!
110+
public var fetchVestingLocksForCurrencyIdClosure: ((AccountId, CurrencyId?) throws -> Decimal)?
111+
112+
public func fetchVestingLocks(for accountId: AccountId, currencyId: CurrencyId?) throws -> Decimal {
113+
if let error = fetchVestingLocksForCurrencyIdThrowableError {
114+
throw error
115+
}
116+
fetchVestingLocksForCurrencyIdCallsCount += 1
117+
fetchVestingLocksForCurrencyIdReceivedArguments = (accountId: accountId, currencyId: currencyId)
118+
fetchVestingLocksForCurrencyIdReceivedInvocations.append((accountId: accountId, currencyId: currencyId))
119+
return try fetchVestingLocksForCurrencyIdClosure.map({ try $0(accountId, currencyId) }) ?? fetchVestingLocksForCurrencyIdReturnValue
120+
}
121+
122+
//MARK: - fetchTotalLocks
123+
124+
public var fetchTotalLocksForCurrencyIdThrowableError: Error?
125+
public var fetchTotalLocksForCurrencyIdCallsCount = 0
126+
public var fetchTotalLocksForCurrencyIdCalled: Bool {
127+
return fetchTotalLocksForCurrencyIdCallsCount > 0
128+
}
129+
public var fetchTotalLocksForCurrencyIdReceivedArguments: (accountId: AccountId, currencyId: CurrencyId?)?
130+
public var fetchTotalLocksForCurrencyIdReceivedInvocations: [(accountId: AccountId, currencyId: CurrencyId?)] = []
131+
public var fetchTotalLocksForCurrencyIdReturnValue: Decimal!
132+
public var fetchTotalLocksForCurrencyIdClosure: ((AccountId, CurrencyId?) throws -> Decimal)?
133+
134+
public func fetchTotalLocks(for accountId: AccountId, currencyId: CurrencyId?) throws -> Decimal {
135+
if let error = fetchTotalLocksForCurrencyIdThrowableError {
136+
throw error
137+
}
138+
fetchTotalLocksForCurrencyIdCallsCount += 1
139+
fetchTotalLocksForCurrencyIdReceivedArguments = (accountId: accountId, currencyId: currencyId)
140+
fetchTotalLocksForCurrencyIdReceivedInvocations.append((accountId: accountId, currencyId: currencyId))
141+
return try fetchTotalLocksForCurrencyIdClosure.map({ try $0(accountId, currencyId) }) ?? fetchTotalLocksForCurrencyIdReturnValue
142+
}
143+
144+
//MARK: - fetchAssetLocks
145+
146+
public var fetchAssetLocksForCurrencyIdThrowableError: Error?
147+
public var fetchAssetLocksForCurrencyIdCallsCount = 0
148+
public var fetchAssetLocksForCurrencyIdCalled: Bool {
149+
return fetchAssetLocksForCurrencyIdCallsCount > 0
150+
}
151+
public var fetchAssetLocksForCurrencyIdReceivedArguments: (accountId: AccountId, currencyId: CurrencyId?)?
152+
public var fetchAssetLocksForCurrencyIdReceivedInvocations: [(accountId: AccountId, currencyId: CurrencyId?)] = []
153+
public var fetchAssetLocksForCurrencyIdReturnValue: Decimal!
154+
public var fetchAssetLocksForCurrencyIdClosure: ((AccountId, CurrencyId?) throws -> Decimal)?
155+
156+
public func fetchAssetLocks(for accountId: AccountId, currencyId: CurrencyId?) throws -> Decimal {
157+
if let error = fetchAssetLocksForCurrencyIdThrowableError {
158+
throw error
159+
}
160+
fetchAssetLocksForCurrencyIdCallsCount += 1
161+
fetchAssetLocksForCurrencyIdReceivedArguments = (accountId: accountId, currencyId: currencyId)
162+
fetchAssetLocksForCurrencyIdReceivedInvocations.append((accountId: accountId, currencyId: currencyId))
163+
return try fetchAssetLocksForCurrencyIdClosure.map({ try $0(accountId, currencyId) }) ?? fetchAssetLocksForCurrencyIdReturnValue
164+
}
165+
166+
//MARK: - fetchAssetFrozen
167+
168+
public var fetchAssetFrozenForCurrencyIdThrowableError: Error?
169+
public var fetchAssetFrozenForCurrencyIdCallsCount = 0
170+
public var fetchAssetFrozenForCurrencyIdCalled: Bool {
171+
return fetchAssetFrozenForCurrencyIdCallsCount > 0
172+
}
173+
public var fetchAssetFrozenForCurrencyIdReceivedArguments: (accountId: AccountId, currencyId: CurrencyId?)?
174+
public var fetchAssetFrozenForCurrencyIdReceivedInvocations: [(accountId: AccountId, currencyId: CurrencyId?)] = []
175+
public var fetchAssetFrozenForCurrencyIdReturnValue: Decimal!
176+
public var fetchAssetFrozenForCurrencyIdClosure: ((AccountId, CurrencyId?) throws -> Decimal)?
177+
178+
public func fetchAssetFrozen(for accountId: AccountId, currencyId: CurrencyId?) throws -> Decimal {
179+
if let error = fetchAssetFrozenForCurrencyIdThrowableError {
180+
throw error
181+
}
182+
fetchAssetFrozenForCurrencyIdCallsCount += 1
183+
fetchAssetFrozenForCurrencyIdReceivedArguments = (accountId: accountId, currencyId: currencyId)
184+
fetchAssetFrozenForCurrencyIdReceivedInvocations.append((accountId: accountId, currencyId: currencyId))
185+
return try fetchAssetFrozenForCurrencyIdClosure.map({ try $0(accountId, currencyId) }) ?? fetchAssetFrozenForCurrencyIdReturnValue
186+
}
187+
188+
//MARK: - fetchAssetBlocked
189+
190+
public var fetchAssetBlockedForCurrencyIdThrowableError: Error?
191+
public var fetchAssetBlockedForCurrencyIdCallsCount = 0
192+
public var fetchAssetBlockedForCurrencyIdCalled: Bool {
193+
return fetchAssetBlockedForCurrencyIdCallsCount > 0
194+
}
195+
public var fetchAssetBlockedForCurrencyIdReceivedArguments: (accountId: AccountId, currencyId: CurrencyId?)?
196+
public var fetchAssetBlockedForCurrencyIdReceivedInvocations: [(accountId: AccountId, currencyId: CurrencyId?)] = []
197+
public var fetchAssetBlockedForCurrencyIdReturnValue: Decimal!
198+
public var fetchAssetBlockedForCurrencyIdClosure: ((AccountId, CurrencyId?) throws -> Decimal)?
199+
200+
public func fetchAssetBlocked(for accountId: AccountId, currencyId: CurrencyId?) throws -> Decimal {
201+
if let error = fetchAssetBlockedForCurrencyIdThrowableError {
202+
throw error
203+
}
204+
fetchAssetBlockedForCurrencyIdCallsCount += 1
205+
fetchAssetBlockedForCurrencyIdReceivedArguments = (accountId: accountId, currencyId: currencyId)
206+
fetchAssetBlockedForCurrencyIdReceivedInvocations.append((accountId: accountId, currencyId: currencyId))
207+
return try fetchAssetBlockedForCurrencyIdClosure.map({ try $0(accountId, currencyId) }) ?? fetchAssetBlockedForCurrencyIdReturnValue
208+
}
209+
210+
}

Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ abstract_target 'fearlessAll' do
1515
pod 'ReachabilitySwift'
1616
pod 'SnapKit', '~> 5.0.0'
1717
pod 'SwiftFormat/CLI', '~> 0.47.13'
18-
pod 'Sourcery', '~> 1.4'
18+
pod 'Sourcery'
1919
pod 'Kingfisher', '7.10.2' , :inhibit_warnings => true
2020
pod 'SVGKit'
2121
pod 'Charts', '~> 4.1.0'

Podfile.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ PODS:
6565
- SoraUI/PinView (1.10.3):
6666
- SoraUI/Controls
6767
- SoraUI/Skrull (1.10.3)
68-
- Sourcery (1.9.2):
69-
- Sourcery/CLI-Only (= 1.9.2)
70-
- Sourcery/CLI-Only (1.9.2)
68+
- Sourcery (2.2.5):
69+
- Sourcery/CLI-Only (= 2.2.5)
70+
- Sourcery/CLI-Only (2.2.5)
7171
- SVGKit (3.0.0):
7272
- CocoaLumberjack (~> 3.0)
7373
- SwiftAlgorithms (1.0.0)
@@ -86,7 +86,7 @@ DEPENDENCIES:
8686
- SoraFoundation (~> 1.0.0)
8787
- SoraKeystore (from `https://github.com/soramitsu/keystore-iOS.git`, tag `1.0.1`)
8888
- SoraUI (~> 1.10.3)
89-
- Sourcery (~> 1.4)
89+
- Sourcery
9090
- SVGKit
9191
- SwiftFormat/CLI (~> 0.47.13)
9292
- SwiftLint
@@ -141,13 +141,13 @@ SPEC CHECKSUMS:
141141
SoraFoundation: 988d90ee3159311b02e42aeba0cf7e85d8bc724c
142142
SoraKeystore: e1789fe41412606d8a1116b86bd00d46d4cb9ccb
143143
SoraUI: 1ec71151eb962591eeb898bcdd98bded59745f2d
144-
Sourcery: 179539341c2261068528cd15a31837b7238fd901
144+
Sourcery: 088e2f5a70844da8bc439f9eb9d88f35fc702f93
145145
SVGKit: 1ad7513f8c74d9652f94ed64ddecda1a23864dea
146146
SwiftAlgorithms: 38dda4731d19027fdeee1125f973111bf3386b53
147147
SwiftFormat: 73573b89257437c550b03d934889725fbf8f75e5
148148
SwiftLint: c1de071d9d08c8aba837545f6254315bc900e211
149149
SwiftyBeaver: 014b0c12065026b731bac80305294f27d63e27f6
150150

151-
PODFILE CHECKSUM: 2765a7ef34d447c0c0be3417855e8ee9fdaba23c
151+
PODFILE CHECKSUM: a6cedc825b985ec1f7bf991d27b20590e39d9278
152152

153153
COCOAPODS: 1.15.2
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
sources:
2+
include:
3+
- ../../fearless
4+
templates:
5+
- ../Templates/AutoMockable.stencil
6+
output:
7+
../../FearlessTestCaravan/Mocks
8+
args:
9+
autoMockableTestableImports: ["fearless"]

0 commit comments

Comments
 (0)