Merge pull request #1185 from LukasKorba/1184-FirstUnenhancedHeight-not-called

[#1184] FirstUnenhancedHeight not called
This commit is contained in:
Lukas Korba 2023-08-04 11:08:07 +02:00 committed by GitHub
commit 4d95f2cb9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 17 deletions

View File

@ -29,6 +29,7 @@ extension ComputeSyncControlDataAction: Action {
await latestBlocksDataProvider.updateScannedData()
await latestBlocksDataProvider.updateBlockData()
await latestBlocksDataProvider.updateUnenhancedData()
// Here we know:
// - latest scanned height from the DB, if none the wallet's birthday is automatically used

View File

@ -16,6 +16,7 @@ protocol LatestBlocksDataProvider {
func updateScannedData() async
func updateBlockData() async
func updateUnenhancedData() async
func updateWalletBirthday(_ walletBirthday: BlockHeight) async
func updateLatestScannedHeight(_ latestScannedHeight: BlockHeight) async
func updateLatestScannedTime(_ latestScannedTime: TimeInterval) async
@ -57,6 +58,10 @@ actor LatestBlocksDataProviderImpl: LatestBlocksDataProvider {
}
}
func updateUnenhancedData() async {
firstUnenhancedHeight = try? transactionRepository.firstUnenhancedHeight()
}
func updateWalletBirthday(_ walletBirthday: BlockHeight) async {
self.walletBirthday = walletBirthday
}

View File

@ -135,6 +135,7 @@ final class ComputeSyncControlDataActionTests: ZcashTestCase {
latestBlocksDataProviderMock.underlyingLatestScannedHeight = 1
latestBlocksDataProviderMock.updateScannedDataClosure = { }
latestBlocksDataProviderMock.updateBlockDataClosure = { }
latestBlocksDataProviderMock.updateUnenhancedDataClosure = { }
loggerMock.debugFileFunctionLineClosure = { _, _, _, _ in }
return setupAction(

View File

@ -546,6 +546,19 @@ class LatestBlocksDataProviderMock: LatestBlocksDataProvider {
await updateBlockDataClosure!()
}
// MARK: - updateUnenhancedData
var updateUnenhancedDataCallsCount = 0
var updateUnenhancedDataCalled: Bool {
return updateUnenhancedDataCallsCount > 0
}
var updateUnenhancedDataClosure: (() async -> Void)?
func updateUnenhancedData() async {
updateUnenhancedDataCallsCount += 1
await updateUnenhancedDataClosure!()
}
// MARK: - updateWalletBirthday
var updateWalletBirthdayCallsCount = 0
@ -2613,29 +2626,27 @@ actor ZcashRustBackendWeldingMock: ZcashRustBackendWelding {
// MARK: - scanBlocks
var scanBlocksLimitThrowableError: Error?
func setScanBlocksLimitThrowableError(_ param: Error?) async {
scanBlocksLimitThrowableError = param
var scanBlocksFromHeightLimitThrowableError: Error?
func setScanBlocksFromHeightLimitThrowableError(_ param: Error?) async {
scanBlocksFromHeightLimitThrowableError = param
}
var scanBlocksLimitCallsCount = 0
var scanBlocksLimitCalled: Bool {
return scanBlocksLimitCallsCount > 0
var scanBlocksFromHeightLimitCallsCount = 0
var scanBlocksFromHeightLimitCalled: Bool {
return scanBlocksFromHeightLimitCallsCount > 0
}
var scanBlocksLimitReceivedFromHeight: Int32?
var scanBlocksLimitReceivedLimit: UInt32?
var scanBlocksLimitClosure: ((Int32, UInt32) async throws -> Void)?
func setScanBlocksLimitClosure(_ param: ((Int32, UInt32) async throws -> Void)?) async {
scanBlocksLimitClosure = param
var scanBlocksFromHeightLimitReceivedArguments: (fromHeight: Int32, limit: UInt32)?
var scanBlocksFromHeightLimitClosure: ((Int32, UInt32) async throws -> Void)?
func setScanBlocksFromHeightLimitClosure(_ param: ((Int32, UInt32) async throws -> Void)?) async {
scanBlocksFromHeightLimitClosure = param
}
func scanBlocks(fromHeight: Int32, limit: UInt32) async throws {
if let error = scanBlocksLimitThrowableError {
if let error = scanBlocksFromHeightLimitThrowableError {
throw error
}
scanBlocksLimitCallsCount += 1
scanBlocksLimitReceivedFromHeight = fromHeight
scanBlocksLimitReceivedLimit = limit
try await scanBlocksLimitClosure!(fromHeight, limit)
scanBlocksFromHeightLimitCallsCount += 1
scanBlocksFromHeightLimitReceivedArguments = (fromHeight: fromHeight, limit: limit)
try await scanBlocksFromHeightLimitClosure!(fromHeight, limit)
}
// MARK: - putUnspentTransparentOutput

View File

@ -142,7 +142,7 @@ class RustBackendMockHelper {
try await rustBackend.suggestScanRanges()
}
await rustBackendMock.setScanBlocksLimitClosure() { fromHeight, limit in
await rustBackendMock.setScanBlocksFromHeightLimitClosure() { fromHeight, limit in
try await rustBackend.scanBlocks(fromHeight: fromHeight, limit: limit)
}
}