[#778] Add swiflint config file only for tests

Closes #778

- .swiftlint.yml is now used to lint only the code of the SDK.
- .swiftlint_tests.yml is now used to lint only the code of the tests.
  This config disables rules that were previously disabled in the code
  in lot of tests.
This commit is contained in:
Michal Fousek 2023-02-13 12:53:47 +01:00
parent 02e4968ea3
commit 65d6347bcf
47 changed files with 214 additions and 95 deletions

View File

@ -3,7 +3,6 @@
included:
- Sources/ZcashLightClientKit/
- Tests/
- Example/ZcashLightClientSample/ZcashLightClientSample
- Example/ZcashLightClientSample/ZcashLightClientSampleTests
@ -12,9 +11,7 @@ excluded:
- Sources/ZcashLightClientKit/Modules/Service/GRPC/ProtoBuf/compact_formats.pb.swift
- Sources/ZcashLightClientKit/Modules/Service/GRPC/ProtoBuf/service.pb.swift
- Sources/ZcashLightClientKit/Modules/Service/GRPC/ProtoBuf/service.grpc.swift
- Tests/TestUtils/proto
- Tests/TestUtils/TestVector.swift
- Tests/OfflineTests/BirthdayTests.swift
- Tests/
- ZcashLightClientKitTests/Constants.generated.swift
- build/
- docs/

160
.swiftlint_tests.yml Normal file
View File

@ -0,0 +1,160 @@
# This SwiftLint file is based on this great guideline.
# https://github.com/raywenderlich/swift-style-guide
included:
- Tests/
excluded:
- Tests/TestUtils/proto/
- xctemplates/
- Sources/
- ZcashLightClientKitTests/Constants.generated.swift
- build/
- docs/
disabled_rules:
- notification_center_detachment
- orphaned_doc_comment
- todo
- unused_capture_list
- nesting # allow for types to be nested, common pattern in Swift
- multiple_closures_with_trailing_closure
- generic_type_name # allow for arbitrarily long generic type names
- redundant_void_return
- implicitly_unwrapped_optional
- force_unwrapping
- type_body_length
- function_body_length
- file_length
- cyclomatic_complexity
- force_cast
- force_try
- function_parameter_count
- identifier_name
opt_in_rules:
- mark
- array_init
- attributes
- closure_end_indentation
- closure_spacing
- collection_alignment
- colon # promote to error
- convenience_type
- discouraged_object_literal
- empty_collection_literal
- empty_count
- empty_string
- enum_case_associated_values_count
- fatal_error_message
- first_where
- indentation_width
- last_where
- legacy_random
- literal_expression_end_indentation
- multiline_arguments
- multiline_arguments_brackets
- multiline_function_chains
- multiline_literal_brackets
- multiline_parameters
- multiline_parameters_brackets
- no_space_in_method_call
- operator_usage_whitespace
- overridden_super_call
- pattern_matching_keywords
- prefer_self_type_over_type_of_self
- redundant_nil_coalescing
- redundant_type_annotation
- return_arrow_whitespace
- strict_fileprivate
- toggle_bool
# - trailing_closure # weird in SwiftUI
- unneeded_parentheses_in_closure_argument
- vertical_whitespace_closing_braces
- vertical_whitespace_opening_braces
- weak_delegate
- yoda_condition
- todos
analyzer_rules:
- unused_import
custom_rules:
array_constructor:
name: "Array/Dictionary initializer"
regex: '[let,var] .+ = (\[.+\]\(\))'
capture_group: 1
message: "Use explicit type annotation when initializing empty arrays and dictionaries"
severity: warning
string_concatenation:
included: ".*\\.swift"
excluded: ".*Test\\.swift"
name: "String Concatenation"
regex: " \\+ \"|\" \\+ |\\+= \""
message: "Please use string interpolation instead of concatenation"
severity: error
nslog_function_usage:
included: ".*\\.swift"
excluded: ".*Test\\.swift"
name: "Swift NSLog() should not be used in App Code"
regex: "NSLog\\("
message: "The swift NSLog function should not be used."
severity: error
todos:
included: ".*\\.swift"
name: "TODO"
regex: '(TODO|FIXME):\ ([^\[]|\[[^#]|\[#[^1-9])'
message: "TODO or FIXME without issue number. Format TODO: [#...]"
severity: warning
match_kinds:
- comment
attributes:
always_on_same_line:
- "@IBSegueAction"
- "@IBAction"
- "@NSManaged"
- "@objc"
legacy_hashing: error
identifier_name:
excluded:
- i
- id
- x
- y
- z
- to
- at
- db
- ua
- nf
- tx
- as
indentation_width:
indentation_width: 4
line_length:
warning: 150
ignores_urls: true
ignores_function_declarations: true
ignores_comments: true
multiline_arguments:
first_argument_location: next_line
only_enforce_after_first_closure_on_first_line: true
private_over_fileprivate:
validate_extensions: true
trailing_whitespace:
ignores_empty_lines: true
ignores_comments: true
vertical_whitespace:
max_empty_lines: 1

View File

@ -475,7 +475,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "cd ../../\n./Tools/swiftlint lint --config .swiftlint.yml\n";
shellScript = "cd ../../\necho \"Linting the SDK code\"\n./Tools/swiftlint lint --config .swiftlint.yml\necho \"Linting tests\"\n./Tools/swiftlint lint --config .swiftlint_tests.yml\n";
};
0DCB58A4237B5B580040096C /* Swiftlint */ = {
isa = PBXShellScriptBuildPhase;
@ -494,7 +494,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "cd ../../\n./Tools/swiftlint lint --config .swiftlint.yml\n";
shellScript = "cd ../../\necho \"Linting the SDK code\"\n./Tools/swiftlint lint --config .swiftlint.yml\necho \"Linting tests\"\n./Tools/swiftlint lint --config .swiftlint_tests.yml\n";
};
/* End PBXShellScriptBuildPhase section */

View File

@ -49,7 +49,8 @@ let package = Package(
.copy("Resources/darkside_pending.db"),
.copy("Resources/sandblasted_mainnet_block.json"),
.copy("Resources/txBase64String.txt"),
.copy("Resources/txFromAndroidSDK.txt")
.copy("Resources/txFromAndroidSDK.txt"),
.copy("Resources/integerOverflowJSON.json")
]
),
.testTarget(

View File

@ -10,7 +10,6 @@ import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit
// swiftlint:disable implicitly_unwrapped_optional force_unwrapping force_try type_body_length file_length cyclomatic_complexity
class AdvancedReOrgTests: XCTestCase {
// TODO: [#715] Parameterize this from environment, https://github.com/zcash/ZcashLightClientKit/issues/715
// swiftlint:disable:next line_length

View File

@ -9,7 +9,6 @@ import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit
// swiftlint:disable type_body_length implicitly_unwrapped_optional force_unwrapping file_length
class BalanceTests: XCTestCase {
// TODO: [#715] Parameterize this from environment, https://github.com/zcash/ZcashLightClientKit/issues/715?
// swiftlint:disable:next line_length
@ -529,7 +528,6 @@ class BalanceTests: XCTestCase {
Sent: (previous available funds - spent note + change) equals to (previous available funds - sent amount)
Error: previous available funds equals to current funds
*/
// swiftlint:disable cyclomatic_complexity
func testVerifyAvailableBalanceDuringSend() async throws {
try FakeChainBuilder.buildChain(darksideWallet: coordinator.service, branchID: branchID, chainName: chainName)

View File

@ -10,7 +10,6 @@ import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit
// swiftlint:disable implicitly_unwrapped_optional force_cast
class BlockDownloaderTests: XCTestCase {
let branchID = "2bb40e60"
let chainName = "main"

View File

@ -10,7 +10,6 @@ import Foundation
import XCTest
@testable import ZcashLightClientKit
// swiftlint:disable implicitly_unwrapped_optional
class DarksideSanityCheckTests: XCTestCase {
// TODO: [#715] Parameterize this from environment, https://github.com/zcash/ZcashLightClientKit/issues/715?
// swiftlint:disable:next line_length

View File

@ -4,7 +4,6 @@
//
// Created by Francisco Gindre on 1/26/23.
//
// swiftlint:disable:all implicitly_unwrapped_optional force_unwrapping
import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit

View File

@ -9,7 +9,6 @@ import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit
// swiftlint:disable implicitly_unwrapped_optional
class PendingTransactionUpdatesTest: XCTestCase {
// TODO: [#715] Parameterize this from environment, https://github.com/zcash/ZcashLightClientKit/issues/715?
// swiftlint:disable:next line_length
@ -88,7 +87,6 @@ class PendingTransactionUpdatesTest: XCTestCase {
LoggerProxy.info("2. send transaction to recipient address")
do {
let pendingTx = try await coordinator.synchronizer.sendToAddress(
// swiftlint:disable:next force_unwrapping
spendingKey: self.coordinator.spendingKeys!.first!,
zatoshi: Zatoshi(20000),
toAddress: try Recipient(testRecipientAddress, network: self.network.networkType),

View File

@ -22,7 +22,6 @@ basic reorg test. Scan, get a reorg and then reach latest height.
* observe that the prev hash of that block does not match the hash that we have for 663250
* rewind 10 blocks and request blocks 663241 to 663251
*/
// swiftlint:disable implicitly_unwrapped_optional print_function_usage function_parameter_count
class ReOrgTests: XCTestCase {
// TODO: [#715] Parameterize this from environment, https://github.com/zcash/ZcashLightClientKit/issues/715?
// swiftlint:disable:next line_length

View File

@ -10,7 +10,6 @@ import XCTest
@testable import ZcashLightClientKit
// FIXME: [#586] disabled until this is resolved https://github.com/zcash/ZcashLightClientKit/issues/586
// swiftlint:disable type_body_length implicitly_unwrapped_optional force_try
class RewindRescanTests: XCTestCase {
// TODO: [#715] Parameterize this from environment, https://github.com/zcash/ZcashLightClientKit/issues/715?
// swiftlint:disable:next line_length

View File

@ -21,7 +21,6 @@ class ShieldFundsTests: XCTestCase {
let sendAmount = Zatoshi(1000)
var birthday: BlockHeight = 1631000
// swiftlint:disable:next implicitly_unwrapped_optional
var coordinator: TestCoordinator!
var syncedExpectation = XCTestExpectation(description: "synced")
var sentTransactionExpectation = XCTestExpectation(description: "sent")
@ -84,7 +83,6 @@ class ShieldFundsTests: XCTestCase {
/// 15. sync up to the new chain tip
/// verify that the shielded transactions are confirmed
///
// swiftlint:disable:next cyclomatic_complexity function_body_length
func testShieldFunds() async throws {
// 1. load the dataset
try coordinator.service.useDataset(from: "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/shield-funds/1631000.txt")

View File

@ -10,7 +10,6 @@ import Combine
@testable import TestUtils
@testable import ZcashLightClientKit
// swiftlint:disable implicitly_unwrapped_optional
class SychronizerDarksideTests: XCTestCase {
// TODO: [#715] Parameterize this from environment, https://github.com/zcash/ZcashLightClientKit/issues/715?
// swiftlint:disable:next line_length

View File

@ -10,7 +10,6 @@ import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit
// swiftlint:disable implicitly_unwrapped_optional force_unwrapping
final class SynchronizerTests: XCTestCase {
// TODO: [#715] Parameterize this from environment, https://github.com/zcash/ZcashLightClientKit/issues/715?
// swiftlint:disable:next line_length

View File

@ -10,7 +10,6 @@ import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit
// swiftlint:disable implicitly_unwrapped_optional force_try
class TransactionEnhancementTests: XCTestCase {
var cancellables: [AnyCancellable] = []
let processorEventHandler = CompactBlockProcessorEventHandler()

View File

@ -9,7 +9,6 @@ import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit
// swiftlint:disable force_unwrapping implicitly_unwrapped_optional force_try
class Z2TReceiveTests: XCTestCase {
// TODO: [#715] Parameterize this from environment, https://github.com/zcash/ZcashLightClientKit/issues/715?
// swiftlint:disable:next line_length

View File

@ -12,7 +12,6 @@ import SQLite
@testable import TestUtils
@testable import ZcashLightClientKit
// swiftlint:disable implicitly_unwrapped_optional force_try print_function_usage
class BlockScanTests: XCTestCase {
var cancelables: [AnyCancellable] = []

View File

@ -9,7 +9,6 @@ import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit
// swiftlint:disable print_function_usage
class BlockStreamingTest: XCTestCase {
let testTempDirectory = URL(fileURLWithPath: NSString(
string: NSTemporaryDirectory()

View File

@ -11,7 +11,6 @@ import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit
// swiftlint:disable implicitly_unwrapped_optional
class CompactBlockProcessorTests: XCTestCase {
lazy var processorConfig = {
let pathProvider = DefaultResourceProvider(network: network)

View File

@ -11,7 +11,6 @@ import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit
// swiftlint:disable implicitly_unwrapped_optional force_try
class CompactBlockReorgTests: XCTestCase {
lazy var processorConfig = {
let pathProvider = DefaultResourceProvider(network: network)

View File

@ -11,7 +11,6 @@ import XCTest
@testable import ZcashLightClientKit
import GRPC
// swiftlint:disable implicitly_unwrapped_optional force_unwrapping
class LightWalletServiceTests: XCTestCase {
let network: ZcashNetwork = ZcashNetworkBuilder.network(for: .testnet)

View File

@ -1,4 +1,5 @@
import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit
class BirthdayTests: XCTestCase {
@ -12,7 +13,13 @@ class BirthdayTests: XCTestCase {
height: 1530000,
hash: "0011f78082f26747e02f0ab3525dc34d8df8f69dde273f462fcbf08fe2aa14d6",
time: 1629030383,
saplingTree: "0103ac57cbe96a0f86b78527aa69b21db02318e7e7a6995cbe497a107707825655001001623311941fc8cfac849331dca1ba89a60552eb9dbadd0019f8dfcb5f6ac6c90601b9a73d583be12b8e9c8a7616fe78a65469a2b91bdf02d411951fa261c9e1e64001e64e2365c8064f711643681da68b4fd626b28e5624abb9fb19d13208818b4d6001330c2415a69eddb56d7a0846f03f4c98936607d5c0e7f580748224bd2117e51200000149f61a12a3f8407f4f7bd3e4f619937fa1a09e984a5f7334fcd7734c4ba3e36900000001bab80e68a5c63460d1e5c94ef540940792fa4703fa488b09fdfded97f8ec8a3d00013d2fd009bf8a22d68f720eac19c411c99014ed9c5f85d5942e15d1fc039e28680001f08f39275112dd8905b854170b7f247cf2df18454d4fa94e6e4f9320cca05f24011f8322ef806eb2430dc4a7a41c1b344bea5be946efc7b4349c1c9edb14ff9d39"
saplingTree: """
0103ac57cbe96a0f86b78527aa69b21db02318e7e7a6995cbe497a107707825655001001623311941fc8cfac849331dca1ba89a60552eb9dbadd0019f8dfcb5f6ac6c906\
01b9a73d583be12b8e9c8a7616fe78a65469a2b91bdf02d411951fa261c9e1e64001e64e2365c8064f711643681da68b4fd626b28e5624abb9fb19d13208818b4d600133\
0c2415a69eddb56d7a0846f03f4c98936607d5c0e7f580748224bd2117e51200000149f61a12a3f8407f4f7bd3e4f619937fa1a09e984a5f7334fcd7734c4ba3e3690000\
0001bab80e68a5c63460d1e5c94ef540940792fa4703fa488b09fdfded97f8ec8a3d00013d2fd009bf8a22d68f720eac19c411c99014ed9c5f85d5942e15d1fc039e2868\
0001f08f39275112dd8905b854170b7f247cf2df18454d4fa94e6e4f9320cca05f24011f8322ef806eb2430dc4a7a41c1b344bea5be946efc7b4349c1c9edb14ff9d39
"""
)
XCTAssertEqual(birthday, expected)
@ -28,7 +35,15 @@ class BirthdayTests: XCTestCase {
height: 1340000,
hash: "00000000031bc547da975ebd77d9113b178053f88fb6a1d8511b4f8962c21c4b",
time: 1627846248,
saplingTree: "01ef55e131bf5e7d6737a6e353fe0ff246ba8938a264335457452db2c4023241590113f4e2a1f043d0a303c769d9aac5eeb8b6854d1a64d71b6b86cda2e0eeee07621301206a8d77952d4143cc5ba4d7943261e7145f0f138a81fe37c10e50a487487966012fb54cf3a70cccf01479fefc42e539c92a8215aead4179278cf1e8a302cb4868014574313eb9fd9ee592346fdf27752f698c1f629b044437853972e266e95b56020001be3f0fa5b20bbfa445293d588073dc27a856c92e9903831c6de4455f03d57a0401bb534b0af17c990f836204115aa17d4c2504fa0a675353ec7ae8a7d67510cc46012e2edeb7e5acb0d440dd5b500bec4a6efd6f53ba02c10e3883e23e53d7f91369000183c334e455aeeeb82cceddbe832919324d7011418749fc9dea759cfa6c2cc21501f4a3504117d35efa15f57d5fdd19515b7fb1dd14c3b98b8a91685f0f788db330000000018846ec9170ad4e40a093cfb53162e5211d55377d8d22f826cde7783d30c1dd5f01b35fe4a943a47404f68db220c77b0573e13c3378a65c6f2396f93be7609d8f2a000125911f4524469c00ccb1ba69e64f0ee7380c8d17bbfc76ecd238421b86eb6e09000118f64df255c9c43db708255e7bf6bffd481e5c2f38fe9ed8f3d189f7f9cf2644"
saplingTree: """
01ef55e131bf5e7d6737a6e353fe0ff246ba8938a264335457452db2c4023241590113f4e2a1f043d0a303c769d9aac5eeb8b6854d1a64d71b6b86cda2e0eeee07621301\
206a8d77952d4143cc5ba4d7943261e7145f0f138a81fe37c10e50a487487966012fb54cf3a70cccf01479fefc42e539c92a8215aead4179278cf1e8a302cb4868014574\
313eb9fd9ee592346fdf27752f698c1f629b044437853972e266e95b56020001be3f0fa5b20bbfa445293d588073dc27a856c92e9903831c6de4455f03d57a0401bb534b\
0af17c990f836204115aa17d4c2504fa0a675353ec7ae8a7d67510cc46012e2edeb7e5acb0d440dd5b500bec4a6efd6f53ba02c10e3883e23e53d7f91369000183c334e4\
55aeeeb82cceddbe832919324d7011418749fc9dea759cfa6c2cc21501f4a3504117d35efa15f57d5fdd19515b7fb1dd14c3b98b8a91685f0f788db330000000018846ec\
9170ad4e40a093cfb53162e5211d55377d8d22f826cde7783d30c1dd5f01b35fe4a943a47404f68db220c77b0573e13c3378a65c6f2396f93be7609d8f2a000125911f45\
24469c00ccb1ba69e64f0ee7380c8d17bbfc76ecd238421b86eb6e09000118f64df255c9c43db708255e7bf6bffd481e5c2f38fe9ed8f3d189f7f9cf2644
"""
)
XCTAssertEqual(birthday, expected)
@ -120,15 +135,8 @@ class BirthdayTests: XCTestCase {
}
/// this has height with `Int64.max + 1`
static let integerOverflowJSON: String =
"""
{
"network": "main",
"height": "9223372036854775808",
"hash": "0000000000aefe1d3aaa6908bd9fe99d476afd72ec49be60090d6ee48f9272bf",
"time": 1656499365,
"saplingTree": "0175848b81090fee135ed81677520ee555e72814ec47d77107779f1d958f72903001a5f61227d13a351d6b9744e572fbddfa60de77650f3b355838771ded6e929a401400000000016a6c28ea8d49d0b32f9c8fad56f239fd6f1dabd0eb2771d7877d4b3d714aee6b0001e4cf1a347436f1b700976cfa387833d3dd53eb3e9e7201d68d1fa15735db411e0140e3461535e2391a82f6cc29221432f53cdc62c697f36cd1077bc5c40bed2d230138cbb3e580d3292e0c783e8e37077be9a1e2c7c95cbc6a4a58cf6f51af755170012896f2157ea42af3ce58fa133917712564a148708702ba3dc5235e49ae36be15000001b9db8a4ba52f5cdea9d142ce71601c2890e9dc306018b4a730a9c8c0a7e258260000000134e093f073973de750e85daff57c07a102dbc7bbc77436e99b0074f36f1cbf130000015ec9e9b1295908beed437df4126032ca57ada8e3ebb67067cd22a73c79a84009",
"orchardTree": "01492e49f873e033c8baf296de1a78f34618d2ac1a64eca3769b93918da66e3f37001f000000018d8f2180ce6978074be7b5bec41e993232ac73797ca80ae32f062a5d83ee363c00000114764dc108e86dc2c6d7c20a6e1759027d87029b5dc7e1e6b5be970ecbed913a01186d95ac66b184f8844e57fece62a4d64cfeb73e7ed6e99146e79aacae7f5e00012f9cd86767aea1f11147f65c588f94dce188315c40b22c0fa8751365ba453c280001130cfb41380fdd7836985e2c4c488fdc3d1d1bd4390f350f0e1b8a448f47ac1c012bcbdd308beca04006b18928c4418aad2b3650677289b1b45ea5a21095c5310301100ed4d0a8a440b03f1254ce1efb2d82a94cf001cffa0e7fd6ada813a2688b240130a69de998b87aebcd4c556503a45e559a422ecfbdf2f0e6318a8427e41a7b09017676cfe97afff13797f82f8d631bd29edde424854139c64ab8241e2a2331551401da371f0d3294843fd8f645019a04c07607342c70cf4cc793068355eaccdd671601bc79f0119f97113775379bf58f3f5d9d122766909b797947127b28248ff0720501c1eb3aa1717c2a696ce0aba6c5b5bda44c4eda5cf69ae376cc8b334a2c23fb2b0001374feb2041bfd423c6cc3e064ee2b4705748a082836d39dd723515357fb06e300000000000000000000000"
}
"""
static let integerOverflowJSON = String(
bytes: TestCoordinator.loadResource(name: "integerOverflowJSON", extension: "json"),
encoding: .utf8
)!
}

View File

@ -9,7 +9,6 @@ import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit
// swiftlint:disable force_try type_body_length
class BlockBatchValidationTests: XCTestCase {
let testTempDirectory = URL(fileURLWithPath: NSString(
string: NSTemporaryDirectory()

View File

@ -8,7 +8,6 @@
import XCTest
@testable import ZcashLightClientKit
// swiftlint:disable force_unwrapping
class DerivationToolMainnetTests: XCTestCase {
// TODO: [#715] Parameterize this from environment, https://github.com/zcash/ZcashLightClientKit/issues/715
var seedPhrase = """

View File

@ -9,7 +9,6 @@
import XCTest
@testable import ZcashLightClientKit
// swiftlint:disable force_unwrapping
class DerivationToolTestnetTests: XCTestCase {
// TODO: [#715] Parameterize this from environment, https://github.com/zcash/ZcashLightClientKit/issues/715
var seedPhrase = """

View File

@ -4,7 +4,6 @@
//
// Created by Francisco Gindre on 12/15/22.
//
// swiftlint:disable type_body_length implicitly_unwrapped_optional force_unwrapping
import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit

View File

@ -9,7 +9,6 @@
import XCTest
@testable import ZcashLightClientKit
// swiftlint:disable implicitly_unwrapped_optional
class InternalSyncProgressTests: XCTestCase {
var storage: InternalSyncProgressStorage!
var internalSyncProgress: InternalSyncProgress!

View File

@ -8,7 +8,6 @@
import XCTest
@testable import ZcashLightClientKit
// swiftlint:disable force_unwrapping print_function_usage
class MemoTests: XCTestCase {
/**
Non-utf8 memos are properly ignored

View File

@ -9,7 +9,6 @@ import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit
// swiftlint:disable implicitly_unwrapped_optional force_try
class NotesRepositoryTests: XCTestCase {
var sentNotesRepository: SentNotesRepository!
var receivedNotesRepository: ReceivedNoteRepository!

View File

@ -9,7 +9,6 @@ import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit
// swiftlint:disable implicitly_unwrapped_optional
class PagedTransactionRepositoryTests: XCTestCase {
var pagedTransactionRepository: PaginatedTransactionRepository!
var transactionRepository: TransactionRepository!

View File

@ -9,7 +9,6 @@ import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit
// swiftlint:disable force_try force_unwrapping implicitly_unwrapped_optional
class PendingTransactionRepositoryTests: XCTestCase {
let dbUrl = try! TestDbBuilder.pendingTransactionsDbURL()
let recipient = SaplingAddress(validatedEncoding: "ztestsapling1ctuamfer5xjnnrdr3xdazenljx0mu0gutcf9u9e74tr2d3jwjnt0qllzxaplu54hgc2tyjdc2p6")

View File

@ -10,7 +10,6 @@ import XCTest
@testable import ZcashLightClientKit
@testable import SwiftProtobuf
// swiftlint:disable implicitly_unwrapped_optional force_unwrapping
class RawTransactionTests: XCTestCase {
var rawTx: Data!
var transactionRepository: TransactionSQLDAO!

View File

@ -9,7 +9,6 @@ import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit
// swiftlint:disable implicitly_unwrapped_optional force_unwrapping force_try
class TransactionRepositoryTests: XCTestCase {
var transactionRepository: TransactionRepository!

View File

@ -8,7 +8,6 @@
import XCTest
@testable import TestUtils
// swiftlint:disable force_unwrapping
class TxIdTests: XCTestCase {
func testTxIdAsString() {
let transactionId = "5cf915c5d01007c39d602e08ab59d98aba366e2fb7ac01f2cdad4bf4f8f300bb"

View File

@ -20,7 +20,6 @@ struct EnclosingStruct {
var someStructure: SomeStructure
}
// swiftlint:disable print_function_usage
final class UndescribableTests: XCTestCase {
func testDescriptionIsRedacted() throws {
let info = "important info"

View File

@ -11,7 +11,6 @@ import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit
// swiftlint:disable implicitly_unwrapped_optional force_unwrapping
class WalletTests: XCTestCase {
let testTempDirectory = URL(fileURLWithPath: NSString(
string: NSTemporaryDirectory()

View File

@ -10,7 +10,6 @@ import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit
// swiftlint:disable force_unwrapping implicitly_unwrapped_optional force_try
class ZcashRustBackendTests: XCTestCase {
var dbData: URL!
var dataDbHandle = TestDbHandle(originalDb: TestDbBuilder.prePopulatedDataDbURL()!)

View File

@ -22,7 +22,6 @@ class SynchronizerTests: XCTestCase {
}
}
// swiftlint:disable:next implicitly_unwrapped_optional
var coordinator: TestCoordinator!
let seedPhrase = """

View File

@ -12,7 +12,6 @@ enum FakeChainBuilderError: Error {
case fakeHexDataConversionFailed
}
// swiftlint:disable force_unwrapping function_parameter_count
enum FakeChainBuilder {
static let someOtherTxUrl = "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/transactions/t-shielded-spend.txt"
static let txMainnetBlockUrl = "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/basic-reorg/663150.txt"

View File

@ -5,7 +5,6 @@
// Created by Francisco Gindre on 12/09/2019.
// Copyright © 2019 Electric Coin Company. All rights reserved.
//
// swiftlint:disable force_unwrapping
import Foundation
@testable import ZcashLightClientKit

View File

@ -0,0 +1,8 @@
{
"network": "main",
"height": "9223372036854775808",
"hash": "0000000000aefe1d3aaa6908bd9fe99d476afd72ec49be60090d6ee48f9272bf",
"time": 1656499365,
"saplingTree": "0175848b81090fee135ed81677520ee555e72814ec47d77107779f1d958f72903001a5f61227d13a351d6b9744e572fbddfa60de77650f3b355838771ded6e929a401400000000016a6c28ea8d49d0b32f9c8fad56f239fd6f1dabd0eb2771d7877d4b3d714aee6b0001e4cf1a347436f1b700976cfa387833d3dd53eb3e9e7201d68d1fa15735db411e0140e3461535e2391a82f6cc29221432f53cdc62c697f36cd1077bc5c40bed2d230138cbb3e580d3292e0c783e8e37077be9a1e2c7c95cbc6a4a58cf6f51af755170012896f2157ea42af3ce58fa133917712564a148708702ba3dc5235e49ae36be15000001b9db8a4ba52f5cdea9d142ce71601c2890e9dc306018b4a730a9c8c0a7e258260000000134e093f073973de750e85daff57c07a102dbc7bbc77436e99b0074f36f1cbf130000015ec9e9b1295908beed437df4126032ca57ada8e3ebb67067cd22a73c79a84009",
"orchardTree": "01492e49f873e033c8baf296de1a78f34618d2ac1a64eca3769b93918da66e3f37001f000000018d8f2180ce6978074be7b5bec41e993232ac73797ca80ae32f062a5d83ee363c00000114764dc108e86dc2c6d7c20a6e1759027d87029b5dc7e1e6b5be970ecbed913a01186d95ac66b184f8844e57fece62a4d64cfeb73e7ed6e99146e79aacae7f5e00012f9cd86767aea1f11147f65c588f94dce188315c40b22c0fa8751365ba453c280001130cfb41380fdd7836985e2c4c488fdc3d1d1bd4390f350f0e1b8a448f47ac1c012bcbdd308beca04006b18928c4418aad2b3650677289b1b45ea5a21095c5310301100ed4d0a8a440b03f1254ce1efb2d82a94cf001cffa0e7fd6ada813a2688b240130a69de998b87aebcd4c556503a45e559a422ecfbdf2f0e6318a8427e41a7b09017676cfe97afff13797f82f8d631bd29edde424854139c64ab8241e2a2331551401da371f0d3294843fd8f645019a04c07607342c70cf4cc793068355eaccdd671601bc79f0119f97113775379bf58f3f5d9d122766909b797947127b28248ff0720501c1eb3aa1717c2a696ce0aba6c5b5bda44c4eda5cf69ae376cc8b334a2c23fb2b0001374feb2041bfd423c6cc3e064ee2b4705748a082836d39dd723515357fb06e300000000000000000000000"
}

View File

@ -11,7 +11,6 @@ import GRPC
import SwiftProtobuf
@testable import ZcashLightClientKit
// swiftlint:disable function_parameter_count identifier_name
class AwfulLightWalletService: MockLightWalletService {
override func latestBlockHeight() throws -> BlockHeight {
throw LightWalletServiceError.criticalError
@ -54,7 +53,6 @@ extension LightWalletServiceMockResponse {
}
}
// swiftlint:disable:next type_body_length
class MockRustBackend: ZcashRustBackendWelding {
static var networkType = NetworkType.testnet
static var mockDataDb = false

View File

@ -9,8 +9,6 @@ import Foundation
import XCTest
@testable import ZcashLightClientKit
// swiftlint:disable force_try function_parameter_count force_unwrapping
/// This is the TestCoordinator
/// What does it do? quite a lot.
/// Is it a nice "SOLID" "Clean Code" piece of source code?

View File

@ -37,8 +37,7 @@ struct TestDbHandle {
}
// This requires reference semantics, an enum cannot be used
// swiftlint:disable:next convenience_type
class TestDbBuilder {
enum TestDbBuilder {
enum TestBuilderError: Error {
case generalError
}
@ -127,7 +126,6 @@ class InMemoryDbProvider: ConnectionProvider {
enum StubBlockCreator {
static func createRandomBlockMeta() -> ZcashCompactBlock.Meta {
ZcashCompactBlock.Meta(
// swiftlint:disable:next force_unwrapping
hash: randomData(ofLength: 32)!,
time: UInt32(Date().timeIntervalSince1970),
saplingOutputs: UInt32.random(in: 0 ... 32),

View File

@ -76,7 +76,7 @@ public struct TestVector {
}
public static var testVectors: [TestVector]? {
var vectors = [TestVector]()
var vectors: [TestVector] = []
for rawVector in testVector.dropFirst(2) {
guard let vector = TestVector(from: rawVector) else {
return nil
@ -92,13 +92,7 @@ public struct TestVector {
for varIndex in Indices.allCases {
switch varIndex {
case .p2pkh_bytes,
.p2sh_bytes,
.sapling_raw_addr,
.orchard_raw_addr,
.unknown_bytes,
.root_seed:
case .p2pkh_bytes, .p2sh_bytes, .sapling_raw_addr, .orchard_raw_addr, .unknown_bytes, .root_seed:
guard let keyPath = Self.optionalByteArrayKeyPath(from: varIndex) else {
return nil
}
@ -108,25 +102,23 @@ public struct TestVector {
break
}
guard let hexString = rawVector[varIndex.rawValue] as? String,
let data = hexString.hexadecimal else {
return nil
}
guard
let hexString = rawVector[varIndex.rawValue] as? String,
let data = hexString.hexadecimal
else { return nil }
self[keyPath: keyPath] = data.bytes
case .account,
.diversifier_index:
case .account, .diversifier_index:
guard rawVector[varIndex.rawValue] != nil else { return nil }
guard let keyPath = Self.uintKeyPath(from: varIndex) else { return nil }
guard let optionalValue = rawVector[varIndex.rawValue],
let intValue = optionalValue as? Int,
let uintValue = UInt32(exactly: intValue) else {
return nil
}
guard
let optionalValue = rawVector[varIndex.rawValue],
let intValue = optionalValue as? Int,
let uintValue = UInt32(exactly: intValue)
else { return nil }
self[keyPath: keyPath] = uintValue
case .unified_addr:
@ -134,22 +126,21 @@ public struct TestVector {
guard let keyPath = Self.stringKeyPath(from: varIndex) else { return nil }
guard let optionalValue = rawVector[varIndex.rawValue],
let stringValue = optionalValue as? String else {
return nil
}
guard
let optionalValue = rawVector[varIndex.rawValue],
let stringValue = optionalValue as? String
else { return nil }
self[keyPath: keyPath] = stringValue
case .unknown_typecode:
self.unknown_typecode = rawVector[varIndex.rawValue] as? UInt32
}
}
}
}
public extension String {
/// Create `Data` from hexadecimal string representation
///
/// This creates a `Data` object from hex string. Note, if the string has any spaces or non-hex characters (e.g. starts with '<' and with a '>'), those are ignored and only hex characters are processed.
@ -167,12 +158,13 @@ public extension String {
data.append(num)
}
guard data.count > 0 else { return nil }
guard !data.isEmpty else { return nil }
return data
}
}
// swiftlint:disable line_length
public let testVector: [[Any?]] =
[
["From https://github.com/zcash-hackworks/zcash-test-vectors/blob/master/unified_address.py"],

View File

@ -21,7 +21,6 @@ public enum Constants {
static let address: String = ProcessInfo.processInfo.environment[Environment.lightwalletdKey] ?? "localhost"
}
// swiftlint:disable identifier_name
enum LightWalletEndpointBuilder {
static var `default`: LightWalletEndpoint {
LightWalletEndpoint(address: Constants.address, port: 9067, secure: false)
@ -133,7 +132,6 @@ func parametersReady() -> Bool {
return true
}
// swiftlint:disable force_unwrapping
class TestSeed {
/**
test account: "still champion voice habit trend flight survey between bitter process artefact blind carbon truly provide dizzy crush flush breeze blouse charge solid fish spread"