diff --git a/Sources/ZcashLightClientKit/Block/Actions/ComputeSyncControlDataAction.swift b/Sources/ZcashLightClientKit/Block/Actions/ComputeSyncControlDataAction.swift index 8f3e69f6..c70d8461 100644 --- a/Sources/ZcashLightClientKit/Block/Actions/ComputeSyncControlDataAction.swift +++ b/Sources/ZcashLightClientKit/Block/Actions/ComputeSyncControlDataAction.swift @@ -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 diff --git a/Sources/ZcashLightClientKit/Providers/LatestBlocksDataProvider.swift b/Sources/ZcashLightClientKit/Providers/LatestBlocksDataProvider.swift index f98755dc..2b01794f 100644 --- a/Sources/ZcashLightClientKit/Providers/LatestBlocksDataProvider.swift +++ b/Sources/ZcashLightClientKit/Providers/LatestBlocksDataProvider.swift @@ -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 } diff --git a/Tests/OfflineTests/CompactBlockProcessorActions/ComputeSyncControlDataActionTests.swift b/Tests/OfflineTests/CompactBlockProcessorActions/ComputeSyncControlDataActionTests.swift index 6a1ab50e..40504964 100644 --- a/Tests/OfflineTests/CompactBlockProcessorActions/ComputeSyncControlDataActionTests.swift +++ b/Tests/OfflineTests/CompactBlockProcessorActions/ComputeSyncControlDataActionTests.swift @@ -135,6 +135,7 @@ final class ComputeSyncControlDataActionTests: ZcashTestCase { latestBlocksDataProviderMock.underlyingLatestScannedHeight = 1 latestBlocksDataProviderMock.updateScannedDataClosure = { } latestBlocksDataProviderMock.updateBlockDataClosure = { } + latestBlocksDataProviderMock.updateUnenhancedDataClosure = { } loggerMock.debugFileFunctionLineClosure = { _, _, _, _ in } return setupAction( diff --git a/Tests/TestUtils/Sourcery/GeneratedMocks/AutoMockable.generated.swift b/Tests/TestUtils/Sourcery/GeneratedMocks/AutoMockable.generated.swift index 3f11e9d1..a27cf0dc 100644 --- a/Tests/TestUtils/Sourcery/GeneratedMocks/AutoMockable.generated.swift +++ b/Tests/TestUtils/Sourcery/GeneratedMocks/AutoMockable.generated.swift @@ -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 diff --git a/Tests/TestUtils/Stubs.swift b/Tests/TestUtils/Stubs.swift index 39576c8e..7c15157b 100644 --- a/Tests/TestUtils/Stubs.swift +++ b/Tests/TestUtils/Stubs.swift @@ -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) } }