[#1184] FirstUnenhancedHeight not called

- firstUnenhancedHeight is now properly used
- fixed tests
This commit is contained in:
Lukas Korba 2023-08-04 09:56:57 +02:00
parent b9524ae1ab
commit ad99fdeae8
5 changed files with 35 additions and 17 deletions

View File

@ -29,6 +29,7 @@ extension ComputeSyncControlDataAction: Action {
await latestBlocksDataProvider.updateScannedData() await latestBlocksDataProvider.updateScannedData()
await latestBlocksDataProvider.updateBlockData() await latestBlocksDataProvider.updateBlockData()
await latestBlocksDataProvider.updateUnenhancedData()
// Here we know: // Here we know:
// - latest scanned height from the DB, if none the wallet's birthday is automatically used // - 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 updateScannedData() async
func updateBlockData() async func updateBlockData() async
func updateUnenhancedData() async
func updateWalletBirthday(_ walletBirthday: BlockHeight) async func updateWalletBirthday(_ walletBirthday: BlockHeight) async
func updateLatestScannedHeight(_ latestScannedHeight: BlockHeight) async func updateLatestScannedHeight(_ latestScannedHeight: BlockHeight) async
func updateLatestScannedTime(_ latestScannedTime: TimeInterval) 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 { func updateWalletBirthday(_ walletBirthday: BlockHeight) async {
self.walletBirthday = walletBirthday self.walletBirthday = walletBirthday
} }

View File

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

View File

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

View File

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