-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathMortalEraFactoryTests.swift
45 lines (33 loc) · 1.37 KB
/
MortalEraFactoryTests.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
@testable import fearless
import IrohaCrypto
class MortalEraFactoryTests: XCTestCase {
func testMortalEraPolkadot() {
performMortalEraCalculation(chainId: Chain.polkadot.genesisHash)
}
func testMortalEraKusama() {
performMortalEraCalculation(chainId: Chain.kusama.genesisHash)
}
func testMortalEraWestend() {
performMortalEraCalculation(chainId: Chain.westend.genesisHash)
}
func performMortalEraCalculation(chainId: ChainModel.Id) {
// given
let logger = Logger.shared
do {
let chainRegistry = ChainRegistryFacade.setupForIntegrationTest(
with: SubstrateStorageTestFacade()
)
let connection = chainRegistry.getConnection(for: chainId)!
let runtimeService = chainRegistry.getRuntimeProvider(for: chainId)!
let operationFactory = MortalEraOperationFactory()
let wrapper = operationFactory.createOperation(from: connection, runtimeService: runtimeService)
let operationQueue = OperationQueue()
operationQueue.addOperations(wrapper.allOperations, waitUntilFinished: true)
let era = try wrapper.targetOperation.extractNoCancellableResultData()
logger.info("Did receive era: \(era)")
} catch {
XCTFail("Unexpected error: \(error)")
}
}
}