From d1dd25142370a4703e5fdc2f27510b780715ee95 Mon Sep 17 00:00:00 2001 From: Michal Fousek Date: Fri, 19 May 2023 11:03:12 +0200 Subject: [PATCH] Make linter happy --- .../Block/CompactBlockProcessor.swift | 1 + .../BlockBatchValidationTests.swift | 2 +- .../ScanActionTests.swift | 4 +-- .../ValidateServerActionTests.swift | 25 +++++++++++++++---- .../CompactBlockProcessorOfflineTests.swift | 2 +- .../SynchronizerOfflineTests.swift | 2 +- Tests/TestUtils/TestCoordinator.swift | 2 +- 7 files changed, 27 insertions(+), 11 deletions(-) diff --git a/Sources/ZcashLightClientKit/Block/CompactBlockProcessor.swift b/Sources/ZcashLightClientKit/Block/CompactBlockProcessor.swift index bdac0439..a9d9b3c4 100644 --- a/Sources/ZcashLightClientKit/Block/CompactBlockProcessor.swift +++ b/Sources/ZcashLightClientKit/Block/CompactBlockProcessor.swift @@ -441,6 +441,7 @@ extension CompactBlockProcessor { // This is main loop of the sync process. It simply takes state and try to find action which handles it. If action is found it executes the // action. If action is not found then loop finishes. Thanks to this it's super easy to identify start point of sync process and end points // of sync process without any side effects. + // swiftlint:disable:next cyclomatic_complexity private func run() async { logger.debug("Starting run") await resetContext() diff --git a/Tests/OfflineTests/BlockBatchValidationTests.swift b/Tests/OfflineTests/BlockBatchValidationTests.swift index 904cb399..19ca3859 100644 --- a/Tests/OfflineTests/BlockBatchValidationTests.swift +++ b/Tests/OfflineTests/BlockBatchValidationTests.swift @@ -45,7 +45,7 @@ class BlockBatchValidationTests: ZcashTestCase { testTempDirectory = nil } - // TODO: [1094] review the tests and potentially fix it https://github.com/zcash/ZcashLightClientKit/issues/1094 + // TODO: [#1094] review the tests and potentially fix it https://github.com/zcash/ZcashLightClientKit/issues/1094 // func testBranchIdFailure() async throws { // let network = ZcashNetworkBuilder.network(for: .mainnet) // let service = MockLightWalletService( diff --git a/Tests/OfflineTests/CompactBlockProcessorActions/ScanActionTests.swift b/Tests/OfflineTests/CompactBlockProcessorActions/ScanActionTests.swift index 620782f5..40d4f971 100644 --- a/Tests/OfflineTests/CompactBlockProcessorActions/ScanActionTests.swift +++ b/Tests/OfflineTests/CompactBlockProcessorActions/ScanActionTests.swift @@ -54,7 +54,7 @@ final class ScanActionTests: ZcashTestCase { let syncContext: ActionContext = .init(state: .scan) do { - let _ = try await scanAction.run(with: syncContext) { _ in } + _ = try await scanAction.run(with: syncContext) { _ in } XCTAssertFalse(transactionRepositoryMock.lastScannedHeightCalled, "transactionRepository.lastScannedHeight() is expected to be called.") XCTAssertFalse(loggerMock.debugFileFunctionLineCalled, "logger.debug(...) is expected to be called.") XCTAssertFalse(blockScannerMock.scanBlocksAtTotalProgressRangeDidScanCalled, "blockScanner.scanBlocks(...) is expected to be called.") @@ -74,7 +74,7 @@ final class ScanActionTests: ZcashTestCase { let syncContext = await setupActionContext() do { - let _ = try await scanAction.run(with: syncContext) { _ in } + _ = try await scanAction.run(with: syncContext) { _ in } XCTAssertTrue(transactionRepositoryMock.lastScannedHeightCalled, "transactionRepository.lastScannedHeight() is expected to be called.") XCTAssertFalse(loggerMock.debugFileFunctionLineCalled, "logger.debug(...) is expected to be called.") XCTAssertFalse(blockScannerMock.scanBlocksAtTotalProgressRangeDidScanCalled, "blockScanner.scanBlocks(...) is expected to be called.") diff --git a/Tests/OfflineTests/CompactBlockProcessorActions/ValidateServerActionTests.swift b/Tests/OfflineTests/CompactBlockProcessorActions/ValidateServerActionTests.swift index 66d46b4e..3db087cb 100644 --- a/Tests/OfflineTests/CompactBlockProcessorActions/ValidateServerActionTests.swift +++ b/Tests/OfflineTests/CompactBlockProcessorActions/ValidateServerActionTests.swift @@ -50,7 +50,10 @@ final class ValidateServerActionTests: ZcashTestCase { } catch ZcashError.compactBlockProcessorChainName(let chainName) { XCTAssertEqual(chainName, "invalid") } catch { - XCTFail("testValidateServerAction_ChainNameError is expected to fail but error \(error) doesn't match ZcashError.compactBlockProcessorChainName") + XCTFail(""" + testValidateServerAction_ChainNameError is expected to fail but error \(error) doesn't match \ + ZcashError.compactBlockProcessorChainName + """) } } @@ -66,7 +69,10 @@ final class ValidateServerActionTests: ZcashTestCase { XCTAssertEqual(expected, .mainnet) XCTAssertEqual(found, .testnet) } catch { - XCTFail("testValidateServerAction_NetworkMatchError is expected to fail but error \(error) doesn't match ZcashError.compactBlockProcessorNetworkMismatch") + XCTFail(""" + testValidateServerAction_NetworkMatchError is expected to fail but error \(error) doesn't match \ + ZcashError.compactBlockProcessorNetworkMismatch + """) } } @@ -82,7 +88,10 @@ final class ValidateServerActionTests: ZcashTestCase { XCTAssertEqual(expected, 280_000) XCTAssertEqual(found, 1) } catch { - XCTFail("testValidateServerAction_SaplingActivationError is expected to fail but error \(error) doesn't match ZcashError.compactBlockProcessorSaplingActivationMismatch") + XCTFail(""" + testValidateServerAction_SaplingActivationError is expected to fail but error \(error) doesn't match \ + ZcashError.compactBlockProcessorSaplingActivationMismatch + """) } } @@ -96,7 +105,10 @@ final class ValidateServerActionTests: ZcashTestCase { XCTFail("testValidateServerAction_ConsensusBranchIDError_InvalidRemoteBranch is expected to fail.") } catch ZcashError.compactBlockProcessorConsensusBranchID { } catch { - XCTFail("testValidateServerAction_ConsensusBranchIDError_InvalidRemoteBranch is expected to fail but error \(error) doesn't match ZcashError.compactBlockProcessorConsensusBranchID") + XCTFail(""" + testValidateServerAction_ConsensusBranchIDError_InvalidRemoteBranch is expected to fail but error \(error) doesn't match \ + ZcashError.compactBlockProcessorConsensusBranchID + """) } } @@ -112,7 +124,10 @@ final class ValidateServerActionTests: ZcashTestCase { XCTAssertEqual(expected, -1026109260) XCTAssertEqual(found, 1) } catch { - XCTFail("testValidateServerAction_ConsensusBranchIDError_ValidRemoteBranch is expected to fail but error \(error) doesn't match ZcashError.compactBlockProcessorWrongConsensusBranchId") + XCTFail(""" + testValidateServerAction_ConsensusBranchIDError_ValidRemoteBranch is expected to fail but error \(error) doesn't match \ + ZcashError.compactBlockProcessorWrongConsensusBranchId + """) } } diff --git a/Tests/OfflineTests/CompactBlockProcessorOfflineTests.swift b/Tests/OfflineTests/CompactBlockProcessorOfflineTests.swift index fe775ffa..168ed54a 100644 --- a/Tests/OfflineTests/CompactBlockProcessorOfflineTests.swift +++ b/Tests/OfflineTests/CompactBlockProcessorOfflineTests.swift @@ -39,7 +39,7 @@ class CompactBlockProcessorOfflineTests: ZcashTestCase { try FileManager.default.removeItem(at: testTempDirectory) } - // TODO: [1095] review this test https://github.com/zcash/ZcashLightClientKit/issues/1095 + // TODO: [#1095] review this test https://github.com/zcash/ZcashLightClientKit/issues/1095 // func testComputeProcessingRangeForSingleLoop() async throws { // let network = ZcashNetworkBuilder.network(for: .testnet) // let rustBackend = ZcashRustBackend.makeForTests(fsBlockDbRoot: testTempDirectory, networkType: .testnet) diff --git a/Tests/OfflineTests/SynchronizerOfflineTests.swift b/Tests/OfflineTests/SynchronizerOfflineTests.swift index 2d78c8ed..becc6bae 100644 --- a/Tests/OfflineTests/SynchronizerOfflineTests.swift +++ b/Tests/OfflineTests/SynchronizerOfflineTests.swift @@ -11,7 +11,7 @@ import Foundation import XCTest @testable import ZcashLightClientKit -// TODO: [1098] review tests, after progress reporting some of them may not have a sense anymore +// TODO: [#1098] review tests, after progress reporting some of them may not have a sense anymore // https://github.com/zcash/ZcashLightClientKit/issues/1098 class SynchronizerOfflineTests: ZcashTestCase { let data = TestsData(networkType: .testnet) diff --git a/Tests/TestUtils/TestCoordinator.swift b/Tests/TestUtils/TestCoordinator.swift index b4dd53c1..a6977f0f 100644 --- a/Tests/TestUtils/TestCoordinator.swift +++ b/Tests/TestUtils/TestCoordinator.swift @@ -212,7 +212,7 @@ extension TestCoordinator { func reset(saplingActivation: BlockHeight, branchID: String, chainName: String) throws { Task { await self.synchronizer.blockProcessor.stop() - // TODO: [1102] review and potentially fix/remove commented code https://github.com/zcash/ZcashLightClientKit/issues/1102 + // TODO: [#1102] review and potentially fix/remove commented code https://github.com/zcash/ZcashLightClientKit/issues/1102 // let config = await self.synchronizer.blockProcessor.config // // let newConfig = CompactBlockProcessor.Configuration(