-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathEraCountdownOperationFactoryTests.swift
45 lines (37 loc) · 1.64 KB
/
EraCountdownOperationFactoryTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import XCTest
import RobinHood
import SSFUtils
@testable import fearless
class EraCountdownOperationFactoryTests: XCTestCase {
func testService() {
let operationManager = OperationManagerFacade.sharedManager
let chainId = Chain.kusama.genesisHash
let chainRegistry = ChainRegistryFacade.setupForIntegrationTest(with: SubstrateStorageTestFacade())
let connection = chainRegistry.getConnection(for: chainId)!
let runtimeService = chainRegistry.getRuntimeProvider(for: chainId)!
let keyFactory = StorageKeyFactory()
let storageRequestFactory = StorageRequestFactory(
remoteFactory: keyFactory,
operationManager: operationManager
)
let factory = EraCountdownOperationFactory(storageRequestFactory: storageRequestFactory)
let timeExpectation = XCTestExpectation()
let operationWrapper = factory.fetchCountdownOperationWrapper(
for: connection,
runtimeService: runtimeService
)
operationWrapper.targetOperation.completionBlock = {
do {
let eraCountdown = try operationWrapper.targetOperation.extractNoCancellableResultData()
Logger.shared.info(
"Estimating era completion time (in seconds): \(eraCountdown.timeIntervalTillNextActiveEraStart())"
)
timeExpectation.fulfill()
} catch {
XCTFail(error.localizedDescription)
}
}
operationManager.enqueue(operations: operationWrapper.allOperations, in: .transient)
wait(for: [timeExpectation], timeout: 20)
}
}