parent
1a2e235f05
commit
d3f0a1a80c
|
@ -1,222 +0,0 @@
|
|||
//
|
||||
// BlockScanTests.swift
|
||||
// ZcashLightClientKitTests
|
||||
//
|
||||
// Created by Francisco Gindre on 10/17/19.
|
||||
// Copyright © 2019 Electric Coin Company. All rights reserved.
|
||||
//
|
||||
|
||||
import Combine
|
||||
import XCTest
|
||||
import SQLite
|
||||
@testable import TestUtils
|
||||
@testable import ZcashLightClientKit
|
||||
|
||||
class BlockScanTests: ZcashTestCase {
|
||||
var cancelables: [AnyCancellable] = []
|
||||
|
||||
var dataDbURL: URL!
|
||||
var spendParamsURL: URL!
|
||||
var outputParamsURL: URL!
|
||||
// swiftlint:disable:next line_length
|
||||
var saplingExtendedKey = SaplingExtendedFullViewingKey(validatedEncoding: "zxviewtestsapling1qw88ayg8qqqqpqyhg7jnh9mlldejfqwu46pm40ruwstd8znq3v3l4hjf33qcu2a5e36katshcfhcxhzgyfugj2lkhmt40j45cv38rv3frnghzkxcx73k7m7afw9j7ujk7nm4dx5mv02r26umxqgar7v3x390w2h3crqqgjsjly7jy4vtwzrmustm5yudpgcydw7x78awca8wqjvkqj8p8e3ykt7lrgd7xf92fsfqjs5vegfsja4ekzpfh5vtccgvs5747xqm6qflmtqpr8s9u")
|
||||
|
||||
var walletBirthDay = Checkpoint.birthday(
|
||||
with: 1386000,
|
||||
network: ZcashNetworkBuilder.network(for: .testnet)
|
||||
)
|
||||
|
||||
var rustBackend: ZcashRustBackendWelding!
|
||||
|
||||
var network = ZcashNetworkBuilder.network(for: .testnet)
|
||||
var blockRepository: BlockRepository!
|
||||
|
||||
let testFileManager = FileManager()
|
||||
|
||||
override func setUp() async throws {
|
||||
try await super.setUp()
|
||||
logger = OSLogger(logLevel: .debug)
|
||||
dataDbURL = try! __dataDbURL()
|
||||
spendParamsURL = try! __spendParamsURL()
|
||||
outputParamsURL = try! __outputParamsURL()
|
||||
|
||||
rustBackend = ZcashRustBackend.makeForTests(
|
||||
dbData: dataDbURL,
|
||||
fsBlockDbRoot: testTempDirectory,
|
||||
networkType: network.networkType
|
||||
)
|
||||
|
||||
deleteDBs()
|
||||
|
||||
Dependencies.setup(
|
||||
in: mockContainer,
|
||||
urls: Initializer.URLs(
|
||||
fsBlockDbRoot: testTempDirectory,
|
||||
dataDbURL: dataDbURL,
|
||||
generalStorageURL: testGeneralStorageDirectory,
|
||||
spendParamsURL: spendParamsURL,
|
||||
outputParamsURL: outputParamsURL
|
||||
),
|
||||
alias: .default,
|
||||
networkType: .testnet,
|
||||
endpoint: LightWalletEndpointBuilder.default,
|
||||
loggingPolicy: .default(.debug)
|
||||
)
|
||||
|
||||
mockContainer.mock(type: LatestBlocksDataProvider.self, isSingleton: true) { _ in LatestBlocksDataProviderMock() }
|
||||
mockContainer.mock(type: ZcashRustBackendWelding.self, isSingleton: true) { _ in self.rustBackend }
|
||||
}
|
||||
|
||||
private func deleteDBs() {
|
||||
try? FileManager.default.removeItem(at: dataDbURL)
|
||||
}
|
||||
|
||||
override func tearDownWithError() throws {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
try super.tearDownWithError()
|
||||
try? testFileManager.removeItem(at: dataDbURL)
|
||||
try? testFileManager.removeItem(at: spendParamsURL)
|
||||
try? testFileManager.removeItem(at: outputParamsURL)
|
||||
cancelables = []
|
||||
blockRepository = nil
|
||||
testTempDirectory = nil
|
||||
}
|
||||
|
||||
// func testSingleDownloadAndScan() async throws {
|
||||
// _ = try await rustBackend.initDataDb(seed: nil)
|
||||
//
|
||||
// let endpoint = LightWalletEndpoint(address: "lightwalletd.testnet.electriccoin.co", port: 9067)
|
||||
// let blockCount = 100
|
||||
// let range = network.constants.saplingActivationHeight ... network.constants.saplingActivationHeight + blockCount
|
||||
//
|
||||
// let processorConfig = CompactBlockProcessor.Configuration(
|
||||
// alias: .default,
|
||||
// fsBlockCacheRoot: testTempDirectory,
|
||||
// dataDb: dataDbURL,
|
||||
// spendParamsURL: spendParamsURL,
|
||||
// outputParamsURL: outputParamsURL,
|
||||
// saplingParamsSourceURL: SaplingParamsSourceURL.tests,
|
||||
// walletBirthdayProvider: { [weak self] in self?.walletBirthDay.height ?? .zero },
|
||||
// network: network
|
||||
// )
|
||||
//
|
||||
// mockContainer.mock(type: LightWalletService.self, isSingleton: true) { _ in
|
||||
// LightWalletServiceFactory(endpoint: endpoint).make()
|
||||
// }
|
||||
// try await mockContainer.resolve(CompactBlockRepository.self).create()
|
||||
//
|
||||
// let compactBlockProcessor = CompactBlockProcessor(container: mockContainer, config: processorConfig)
|
||||
//
|
||||
// let repository = BlockSQLDAO(dbProvider: SimpleConnectionProvider.init(path: self.dataDbURL.absoluteString, readonly: true))
|
||||
// var latestScannedheight = BlockHeight.empty()
|
||||
//
|
||||
// try await compactBlockProcessor.blockDownloaderService.downloadBlockRange(range)
|
||||
// XCTAssertFalse(Task.isCancelled)
|
||||
// try await compactBlockProcessor.blockScanner.scanBlocks(at: range, totalProgressRange: range, didScan: { _ in })
|
||||
//
|
||||
// latestScannedheight = repository.lastScannedBlockHeight()
|
||||
// XCTAssertEqual(latestScannedheight, range.upperBound)
|
||||
//
|
||||
// await compactBlockProcessor.stop()
|
||||
// }
|
||||
|
||||
func observeBenchmark(_ metrics: SDKMetrics) {
|
||||
let reports = metrics.popAllBlockReports(flush: true)
|
||||
|
||||
reports.forEach {
|
||||
print("observed benchmark: \($0)")
|
||||
}
|
||||
}
|
||||
|
||||
// func testScanValidateDownload() async throws {
|
||||
// let seed = "testreferencealicetestreferencealice"
|
||||
//
|
||||
// let metrics = SDKMetrics()
|
||||
// metrics.enableMetrics()
|
||||
//
|
||||
// guard try await rustBackend.initDataDb(seed: nil) == .success else {
|
||||
// XCTFail("Seed should not be required for this test")
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// let derivationTool = DerivationTool(networkType: .testnet)
|
||||
// let spendingKey = try derivationTool.deriveUnifiedSpendingKey(seed: Array(seed.utf8), accountIndex: 0)
|
||||
// let viewingKey = try derivationTool.deriveUnifiedFullViewingKey(from: spendingKey)
|
||||
//
|
||||
// do {
|
||||
// try await rustBackend.initAccountsTable(ufvks: [viewingKey])
|
||||
// } catch {
|
||||
// XCTFail("failed to init account table. error: \(error)")
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// try await rustBackend.initBlocksTable(
|
||||
// height: Int32(walletBirthDay.height),
|
||||
// hash: walletBirthDay.hash,
|
||||
// time: walletBirthDay.time,
|
||||
// saplingTree: walletBirthDay.saplingTree
|
||||
// )
|
||||
//
|
||||
// let processorConfig = CompactBlockProcessor.Configuration(
|
||||
// alias: .default,
|
||||
// fsBlockCacheRoot: testTempDirectory,
|
||||
// dataDb: dataDbURL,
|
||||
// spendParamsURL: spendParamsURL,
|
||||
// outputParamsURL: outputParamsURL,
|
||||
// saplingParamsSourceURL: SaplingParamsSourceURL.tests,
|
||||
// batchSize: 1000,
|
||||
// walletBirthdayProvider: { [weak self] in self?.network.constants.saplingActivationHeight ?? .zero },
|
||||
// network: network
|
||||
// )
|
||||
//
|
||||
// mockContainer.mock(type: LightWalletService.self, isSingleton: true) { _ in
|
||||
// LightWalletServiceFactory(endpoint: LightWalletEndpointBuilder.eccTestnet).make()
|
||||
// }
|
||||
// try await mockContainer.resolve(CompactBlockRepository.self).create()
|
||||
//
|
||||
// let compactBlockProcessor = CompactBlockProcessor(container: mockContainer, config: processorConfig)
|
||||
//
|
||||
// let eventClosure: CompactBlockProcessor.EventClosure = { [weak self] event in
|
||||
// switch event {
|
||||
// case .progressUpdated: self?.observeBenchmark(metrics)
|
||||
// default: break
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// await compactBlockProcessor.updateEventClosure(identifier: "tests", closure: eventClosure)
|
||||
//
|
||||
// let range = CompactBlockRange(
|
||||
// uncheckedBounds: (walletBirthDay.height, walletBirthDay.height + 10000)
|
||||
// )
|
||||
//
|
||||
// do {
|
||||
// let blockDownloader = await compactBlockProcessor.blockDownloader
|
||||
// await blockDownloader.setDownloadLimit(range.upperBound)
|
||||
// try await blockDownloader.setSyncRange(range, batchSize: 100)
|
||||
// await blockDownloader.startDownload(maxBlockBufferSize: 10)
|
||||
// try await blockDownloader.waitUntilRequestedBlocksAreDownloaded(in: range)
|
||||
//
|
||||
// XCTAssertFalse(Task.isCancelled)
|
||||
//
|
||||
// try await compactBlockProcessor.blockValidator.validate()
|
||||
// XCTAssertFalse(Task.isCancelled)
|
||||
//
|
||||
// try await compactBlockProcessor.blockScanner.scanBlocks(at: range, totalProgressRange: range, didScan: { _ in })
|
||||
// XCTAssertFalse(Task.isCancelled)
|
||||
// } catch {
|
||||
// if let lwdError = error as? ZcashError {
|
||||
// switch lwdError {
|
||||
// case .serviceBlockStreamFailed:
|
||||
// XCTAssert(true)
|
||||
// default:
|
||||
// XCTFail("LWD Service error found, but should have been a timeLimit reached Error - \(lwdError)")
|
||||
// }
|
||||
// } else {
|
||||
// XCTFail("Error should have been a timeLimit reached Error - \(error)")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// await compactBlockProcessor.stop()
|
||||
// metrics.disableMetrics()
|
||||
// }
|
||||
}
|
|
@ -12,6 +12,13 @@ import XCTest
|
|||
class BlockStreamingTest: ZcashTestCase {
|
||||
let testFileManager = FileManager()
|
||||
var rustBackend: ZcashRustBackendWelding!
|
||||
var endpoint: LightWalletEndpoint!
|
||||
var service: LightWalletService!
|
||||
var storage: FSCompactBlockRepository!
|
||||
var internalSyncProgress: InternalSyncProgress!
|
||||
var processorConfig: CompactBlockProcessor.Configuration!
|
||||
var latestBlockHeight: BlockHeight!
|
||||
var startHeight: BlockHeight!
|
||||
|
||||
override func setUp() async throws {
|
||||
try await super.setUp()
|
||||
|
@ -37,136 +44,177 @@ class BlockStreamingTest: ZcashTestCase {
|
|||
|
||||
mockContainer.mock(type: LatestBlocksDataProvider.self, isSingleton: true) { _ in LatestBlocksDataProviderMock() }
|
||||
mockContainer.mock(type: ZcashRustBackendWelding.self, isSingleton: true) { _ in self.rustBackend }
|
||||
|
||||
let endpoint = LightWalletEndpoint(
|
||||
address: LightWalletEndpointBuilder.eccTestnet.host,
|
||||
port: 9067,
|
||||
secure: true,
|
||||
singleCallTimeoutInMillis: 10000,
|
||||
streamingCallTimeoutInMillis: 10000
|
||||
)
|
||||
let service = LightWalletServiceFactory(endpoint: endpoint).make()
|
||||
|
||||
latestBlockHeight = try await service.latestBlockHeight()
|
||||
startHeight = latestBlockHeight - 10_000
|
||||
}
|
||||
|
||||
override func tearDownWithError() throws {
|
||||
try super.tearDownWithError()
|
||||
rustBackend = nil
|
||||
try? FileManager.default.removeItem(at: __dataDbURL())
|
||||
testTempDirectory = nil
|
||||
endpoint = nil
|
||||
service = nil
|
||||
storage = nil
|
||||
internalSyncProgress = nil
|
||||
processorConfig = nil
|
||||
}
|
||||
|
||||
func testStream() async throws {
|
||||
private func makeDependencies(timeout: Int64) async throws {
|
||||
let endpoint = LightWalletEndpoint(
|
||||
address: LightWalletEndpointBuilder.eccTestnet.host,
|
||||
port: 9067,
|
||||
secure: true,
|
||||
singleCallTimeoutInMillis: 1000,
|
||||
streamingCallTimeoutInMillis: 100000
|
||||
singleCallTimeoutInMillis: timeout,
|
||||
streamingCallTimeoutInMillis: timeout
|
||||
)
|
||||
let service = LightWalletServiceFactory(endpoint: endpoint).make()
|
||||
self.endpoint = endpoint
|
||||
service = LightWalletServiceFactory(endpoint: endpoint).make()
|
||||
storage = FSCompactBlockRepository(
|
||||
fsBlockDbRoot: testTempDirectory,
|
||||
metadataStore: FSMetadataStore.live(
|
||||
fsBlockDbRoot: testTempDirectory,
|
||||
rustBackend: rustBackend,
|
||||
logger: logger
|
||||
),
|
||||
blockDescriptor: .live,
|
||||
contentProvider: DirectoryListingProviders.defaultSorted,
|
||||
logger: logger
|
||||
)
|
||||
try await storage.create()
|
||||
|
||||
let internalSyncProgressStorage = InternalSyncProgressMemoryStorage()
|
||||
try await internalSyncProgressStorage.set(startHeight, for: InternalSyncProgress.Key.latestDownloadedBlockHeight.rawValue)
|
||||
internalSyncProgress = InternalSyncProgress(alias: .default, storage: internalSyncProgressStorage, logger: logger)
|
||||
|
||||
processorConfig = CompactBlockProcessor.Configuration.standard(
|
||||
for: ZcashNetworkBuilder.network(for: .testnet),
|
||||
walletBirthday: ZcashNetworkBuilder.network(for: .testnet).constants.saplingActivationHeight
|
||||
)
|
||||
|
||||
mockContainer.mock(type: LightWalletService.self, isSingleton: true) { _ in
|
||||
LightWalletServiceFactory(endpoint: endpoint).make()
|
||||
}
|
||||
|
||||
let transactionRepositoryMock = TransactionRepositoryMock()
|
||||
transactionRepositoryMock.lastScannedHeightReturnValue = startHeight
|
||||
mockContainer.mock(type: TransactionRepository.self, isSingleton: true) { _ in transactionRepositoryMock }
|
||||
|
||||
let blockDownloader = BlockDownloaderImpl(
|
||||
service: service,
|
||||
downloaderService: BlockDownloaderServiceImpl(service: service, storage: storage),
|
||||
storage: storage,
|
||||
internalSyncProgress: internalSyncProgress,
|
||||
metrics: SDKMetrics(),
|
||||
logger: logger
|
||||
)
|
||||
mockContainer.mock(type: BlockDownloader.self, isSingleton: true) { _ in blockDownloader }
|
||||
}
|
||||
|
||||
func testStream() async throws {
|
||||
try await makeDependencies(timeout: 10000)
|
||||
|
||||
let latestHeight = try await service.latestBlockHeight()
|
||||
|
||||
let startHeight = latestHeight - 100_000
|
||||
var blocks: [ZcashCompactBlock] = []
|
||||
let stream = service.blockStream(startHeight: startHeight, endHeight: latestHeight)
|
||||
let stream = service.blockStream(startHeight: startHeight, endHeight: latestBlockHeight)
|
||||
|
||||
do {
|
||||
for try await compactBlock in stream {
|
||||
print("received block \(compactBlock.height)")
|
||||
blocks.append(compactBlock)
|
||||
print("progressHeight: \(compactBlock.height)")
|
||||
print("startHeight: \(startHeight)")
|
||||
print("targetHeight: \(latestHeight)")
|
||||
}
|
||||
} catch {
|
||||
XCTFail("failed with error: \(error)")
|
||||
}
|
||||
|
||||
XCTAssertEqual(blocks.count, latestBlockHeight - startHeight + 1)
|
||||
}
|
||||
|
||||
func testStreamCancellation() async throws {
|
||||
try await makeDependencies(timeout: 10000)
|
||||
|
||||
let action = DownloadAction(container: mockContainer, configProvider: CompactBlockProcessor.ConfigProvider(config: processorConfig))
|
||||
let syncRanges = SyncRanges(
|
||||
latestBlockHeight: latestBlockHeight,
|
||||
downloadRange: startHeight...latestBlockHeight,
|
||||
scanRange: nil,
|
||||
enhanceRange: nil,
|
||||
fetchUTXORange: nil,
|
||||
latestScannedHeight: startHeight,
|
||||
latestDownloadedBlockHeight: startHeight
|
||||
)
|
||||
let context = ActionContext(state: .download)
|
||||
await context.update(syncRanges: syncRanges)
|
||||
|
||||
let expectation = XCTestExpectation()
|
||||
|
||||
let cancelableTask = Task {
|
||||
do {
|
||||
_ = try await action.run(with: context, didUpdate: { _ in })
|
||||
let lastDownloadedHeight = try await internalSyncProgress.latestDownloadedBlockHeight
|
||||
// Just to be sure that download was interrupted before download was finished.
|
||||
XCTAssertLessThan(lastDownloadedHeight, latestBlockHeight)
|
||||
expectation.fulfill()
|
||||
} catch {
|
||||
XCTFail("Downloading failed with error: \(error)")
|
||||
expectation.fulfill()
|
||||
}
|
||||
}
|
||||
|
||||
DispatchQueue.global().asyncAfter(deadline: .now() + 1.0) {
|
||||
cancelableTask.cancel()
|
||||
}
|
||||
|
||||
await fulfillment(of: [expectation], timeout: 5)
|
||||
await action.stop()
|
||||
}
|
||||
|
||||
// func testStreamCancellation() async throws {
|
||||
// let endpoint = LightWalletEndpoint(
|
||||
// address: LightWalletEndpointBuilder.eccTestnet.host,
|
||||
// port: 9067,
|
||||
// secure: true,
|
||||
// singleCallTimeoutInMillis: 10000,
|
||||
// streamingCallTimeoutInMillis: 10000
|
||||
// )
|
||||
// let service = LightWalletServiceFactory(endpoint: endpoint).make()
|
||||
//
|
||||
// let latestBlockHeight = try await service.latestBlockHeight()
|
||||
// let startHeight = latestBlockHeight - 100_000
|
||||
// let processorConfig = CompactBlockProcessor.Configuration.standard(
|
||||
// for: ZcashNetworkBuilder.network(for: .testnet),
|
||||
// walletBirthday: ZcashNetworkBuilder.network(for: .testnet).constants.saplingActivationHeight
|
||||
// )
|
||||
//
|
||||
// mockContainer.mock(type: LightWalletService.self, isSingleton: true) { _ in
|
||||
// LightWalletServiceFactory(endpoint: endpoint).make()
|
||||
// }
|
||||
// try await mockContainer.resolve(CompactBlockRepository.self).create()
|
||||
//
|
||||
// let compactBlockProcessor = CompactBlockProcessor(container: mockContainer, config: processorConfig)
|
||||
//
|
||||
// let cancelableTask = Task {
|
||||
// do {
|
||||
// let blockDownloader = await compactBlockProcessor.blockDownloader
|
||||
// await blockDownloader.setDownloadLimit(latestBlockHeight)
|
||||
// try await blockDownloader.setSyncRange(startHeight...latestBlockHeight, batchSize: 100)
|
||||
// await blockDownloader.startDownload(maxBlockBufferSize: 10)
|
||||
// try await blockDownloader.waitUntilRequestedBlocksAreDownloaded(in: startHeight...latestBlockHeight)
|
||||
// } catch {
|
||||
// XCTAssertTrue(Task.isCancelled)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// cancelableTask.cancel()
|
||||
// await compactBlockProcessor.stop()
|
||||
// }
|
||||
|
||||
// func testStreamTimeout() async throws {
|
||||
// let endpoint = LightWalletEndpoint(
|
||||
// address: LightWalletEndpointBuilder.eccTestnet.host,
|
||||
// port: 9067,
|
||||
// secure: true,
|
||||
// singleCallTimeoutInMillis: 1000,
|
||||
// streamingCallTimeoutInMillis: 1000
|
||||
// )
|
||||
// let service = LightWalletServiceFactory(endpoint: endpoint).make()
|
||||
//
|
||||
// let latestBlockHeight = try await service.latestBlockHeight()
|
||||
//
|
||||
// let startHeight = latestBlockHeight - 100_000
|
||||
//
|
||||
// let processorConfig = CompactBlockProcessor.Configuration.standard(
|
||||
// for: ZcashNetworkBuilder.network(for: .testnet),
|
||||
// walletBirthday: ZcashNetworkBuilder.network(for: .testnet).constants.saplingActivationHeight
|
||||
// )
|
||||
//
|
||||
// mockContainer.mock(type: LightWalletService.self, isSingleton: true) { _ in
|
||||
// LightWalletServiceFactory(endpoint: endpoint).make()
|
||||
// }
|
||||
// try await mockContainer.resolve(CompactBlockRepository.self).create()
|
||||
//
|
||||
// let compactBlockProcessor = CompactBlockProcessor(container: mockContainer, config: processorConfig)
|
||||
//
|
||||
// let date = Date()
|
||||
//
|
||||
// do {
|
||||
// let blockDownloader = await compactBlockProcessor.blockDownloader
|
||||
// await blockDownloader.setDownloadLimit(latestBlockHeight)
|
||||
// try await blockDownloader.setSyncRange(startHeight...latestBlockHeight, batchSize: 100)
|
||||
// await blockDownloader.startDownload(maxBlockBufferSize: 10)
|
||||
// try await blockDownloader.waitUntilRequestedBlocksAreDownloaded(in: startHeight...latestBlockHeight)
|
||||
// } catch {
|
||||
// if let lwdError = error as? ZcashError {
|
||||
// switch lwdError {
|
||||
// case .serviceBlockStreamFailed:
|
||||
// XCTAssert(true)
|
||||
// default:
|
||||
// XCTFail("LWD Service error found, but should have been a timeLimit reached \(lwdError)")
|
||||
// }
|
||||
// } else {
|
||||
// XCTFail("Error should have been a timeLimit reached Error")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// let now = Date()
|
||||
//
|
||||
// let elapsed = now.timeIntervalSince(date)
|
||||
// print("took \(elapsed) seconds")
|
||||
//
|
||||
// await compactBlockProcessor.stop()
|
||||
// }
|
||||
func testStreamTimeout() async throws {
|
||||
try await makeDependencies(timeout: 100)
|
||||
|
||||
let action = DownloadAction(container: mockContainer, configProvider: CompactBlockProcessor.ConfigProvider(config: processorConfig))
|
||||
let syncRanges = SyncRanges(
|
||||
latestBlockHeight: latestBlockHeight,
|
||||
downloadRange: startHeight...latestBlockHeight,
|
||||
scanRange: nil,
|
||||
enhanceRange: nil,
|
||||
fetchUTXORange: nil,
|
||||
latestScannedHeight: startHeight,
|
||||
latestDownloadedBlockHeight: startHeight
|
||||
)
|
||||
let context = ActionContext(state: .download)
|
||||
await context.update(syncRanges: syncRanges)
|
||||
|
||||
let date = Date()
|
||||
|
||||
do {
|
||||
_ = try await action.run(with: context, didUpdate: { _ in })
|
||||
XCTFail("It is expected that this downloading fails.")
|
||||
} catch {
|
||||
if let lwdError = error as? ZcashError {
|
||||
switch lwdError {
|
||||
case .serviceBlockStreamFailed:
|
||||
XCTAssert(true)
|
||||
default:
|
||||
XCTFail("LWD Service error found, but should have been a timeLimit reached \(lwdError)")
|
||||
}
|
||||
} else {
|
||||
XCTFail("Error should have been a timeLimit reached Error")
|
||||
}
|
||||
}
|
||||
|
||||
let now = Date()
|
||||
|
||||
let elapsed = now.timeIntervalSince(date)
|
||||
print("took \(elapsed) seconds")
|
||||
|
||||
await action.stop()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -287,72 +287,6 @@ class CompactBlockProcessorTests: ZcashTestCase {
|
|||
"Failure when testing last range"
|
||||
)
|
||||
}
|
||||
|
||||
// func testShouldClearBlockCacheReturnsNilWhenScannedHeightEqualsDownloadedHeight() {
|
||||
// /*
|
||||
// downloaded but not scanned: -1...-1
|
||||
// download and scan: 1493120...2255953
|
||||
// enhance range: 1410000...2255953
|
||||
// fetchUTXO range: 1410000...2255953
|
||||
// total progress range: 1493120...2255953
|
||||
// */
|
||||
//
|
||||
// let range = SyncRanges(
|
||||
// latestBlockHeight: 2255953,
|
||||
// downloadedButUnscannedRange: -1 ... -1,
|
||||
// downloadAndScanRange: 1493120...2255953,
|
||||
// enhanceRange: 1410000...2255953,
|
||||
// fetchUTXORange: 1410000...2255953,
|
||||
// latestScannedHeight: 1493119,
|
||||
// latestDownloadedBlockHeight: 1493119
|
||||
// )
|
||||
//
|
||||
// XCTAssertNil(range.shouldClearBlockCacheAndUpdateInternalState())
|
||||
// }
|
||||
|
||||
// func testShouldClearBlockCacheReturnsAHeightWhenScannedIsGreaterThanDownloaded() {
|
||||
// /*
|
||||
// downloaded but not scanned: -1...-1
|
||||
// download and scan: 1493120...2255953
|
||||
// enhance range: 1410000...2255953
|
||||
// fetchUTXO range: 1410000...2255953
|
||||
// total progress range: 1493120...2255953
|
||||
// */
|
||||
//
|
||||
// let range = SyncRanges(
|
||||
// latestBlockHeight: 2255953,
|
||||
// downloadedButUnscannedRange: -1 ... -1,
|
||||
// downloadAndScanRange: 1493120...2255953,
|
||||
// enhanceRange: 1410000...2255953,
|
||||
// fetchUTXORange: 1410000...2255953,
|
||||
// latestScannedHeight: 1493129,
|
||||
// latestDownloadedBlockHeight: 1493119
|
||||
// )
|
||||
//
|
||||
// XCTAssertEqual(range.shouldClearBlockCacheAndUpdateInternalState(), BlockHeight(1493129))
|
||||
// }
|
||||
|
||||
// func testShouldClearBlockCacheReturnsNilWhenScannedIsGreaterThanDownloaded() {
|
||||
// /*
|
||||
// downloaded but not scanned: 1493120...1494120
|
||||
// download and scan: 1494121...2255953
|
||||
// enhance range: 1410000...2255953
|
||||
// fetchUTXO range: 1410000...2255953
|
||||
// total progress range: 1493120...2255953
|
||||
// */
|
||||
//
|
||||
// let range = SyncRanges(
|
||||
// latestBlockHeight: 2255953,
|
||||
// downloadedButUnscannedRange: 1493120...1494120,
|
||||
// downloadAndScanRange: 1494121...2255953,
|
||||
// enhanceRange: 1410000...2255953,
|
||||
// fetchUTXORange: 1410000...2255953,
|
||||
// latestScannedHeight: 1493119,
|
||||
// latestDownloadedBlockHeight: 1494120
|
||||
// )
|
||||
//
|
||||
// XCTAssertNil(range.shouldClearBlockCacheAndUpdateInternalState())
|
||||
// }
|
||||
|
||||
func testDetermineLowerBoundPastBirthday() async {
|
||||
let errorHeight = 781_906
|
||||
|
|
Loading…
Reference in New Issue