diff --git a/Sources/ZcashLightClientKit/Checkpoint/CheckpointSourceFactory.swift b/Sources/ZcashLightClientKit/Checkpoint/CheckpointSourceFactory.swift index 536088912..ab190e1b7 100644 --- a/Sources/ZcashLightClientKit/Checkpoint/CheckpointSourceFactory.swift +++ b/Sources/ZcashLightClientKit/Checkpoint/CheckpointSourceFactory.swift @@ -7,7 +7,7 @@ import Foundation -struct CheckpointSourceFactory { +enum CheckpointSourceFactory { static func fromBundle(for network: NetworkType) -> CheckpointSource { BundleCheckpointSource(network: network) } diff --git a/Tests/DarksideTests/AdvancedReOrgTests.swift b/Tests/DarksideTests/AdvancedReOrgTests.swift index f973fcc1c..d380e5103 100644 --- a/Tests/DarksideTests/AdvancedReOrgTests.swift +++ b/Tests/DarksideTests/AdvancedReOrgTests.swift @@ -28,6 +28,10 @@ class AdvancedReOrgTests: ZcashTestCase { override func setUp() async throws { try await super.setUp() + mockContainer.mock(type: CheckpointSource.self, isSingleton: true) { _ in + return DarksideMainnetCheckpointSource() + } + // don't use an exact birthday, users never do. self.coordinator = try await TestCoordinator( container: mockContainer, diff --git a/Tests/DarksideTests/BalanceTests.swift b/Tests/DarksideTests/BalanceTests.swift index 15c41e7f7..88fe624be 100644 --- a/Tests/DarksideTests/BalanceTests.swift +++ b/Tests/DarksideTests/BalanceTests.swift @@ -26,6 +26,10 @@ class BalanceTests: ZcashTestCase { override func setUp() async throws { try await super.setUp() + mockContainer.mock(type: CheckpointSource.self, isSingleton: true) { _ in + return DarksideMainnetCheckpointSource() + } + self.coordinator = try await TestCoordinator( container: mockContainer, walletBirthday: birthday, diff --git a/Tests/DarksideTests/BlockDownloaderTests.swift b/Tests/DarksideTests/BlockDownloaderTests.swift index dd96e8479..1e48d06fd 100644 --- a/Tests/DarksideTests/BlockDownloaderTests.swift +++ b/Tests/DarksideTests/BlockDownloaderTests.swift @@ -10,7 +10,7 @@ import XCTest @testable import TestUtils @testable import ZcashLightClientKit -class BlockDownloaderTests: XCTestCase { +class BlockDownloaderTests: ZcashTestCase { let branchID = "2bb40e60" let chainName = "main" @@ -21,10 +21,14 @@ class BlockDownloaderTests: XCTestCase { var storage: CompactBlockRepository! var network = DarksideWalletDNetwork() var rustBackend: ZcashRustBackendWelding! - var testTempDirectory: URL! override func setUp() async throws { try await super.setUp() + + mockContainer.mock(type: CheckpointSource.self, isSingleton: true) { _ in + return DarksideMainnetCheckpointSource() + } + testTempDirectory = Environment.uniqueTestTempDirectory service = LightWalletServiceFactory(endpoint: LightWalletEndpointBuilder.default).make() diff --git a/Tests/DarksideTests/DarksideSanityCheckTests.swift b/Tests/DarksideTests/DarksideSanityCheckTests.swift index a7af5e4fe..53bb6fe60 100644 --- a/Tests/DarksideTests/DarksideSanityCheckTests.swift +++ b/Tests/DarksideTests/DarksideSanityCheckTests.swift @@ -27,6 +27,10 @@ class DarksideSanityCheckTests: ZcashTestCase { override func setUp() async throws { try await super.setUp() + mockContainer.mock (type: CheckpointSource.self, isSingleton: true) { _ in + return DarksideMainnetCheckpointSource() + } + self.coordinator = try await TestCoordinator( container: mockContainer, walletBirthday: birthday, diff --git a/Tests/DarksideTests/PendingTransactionUpdatesTest.swift b/Tests/DarksideTests/PendingTransactionUpdatesTest.swift index 42eb62768..e41d939dd 100644 --- a/Tests/DarksideTests/PendingTransactionUpdatesTest.swift +++ b/Tests/DarksideTests/PendingTransactionUpdatesTest.swift @@ -25,6 +25,10 @@ class PendingTransactionUpdatesTest: ZcashTestCase { override func setUp() async throws { try await super.setUp() + mockContainer.mock(type: CheckpointSource.self, isSingleton: true) { _ in + return DarksideMainnetCheckpointSource() + } + self.coordinator = try await TestCoordinator( container: mockContainer, walletBirthday: birthday, diff --git a/Tests/DarksideTests/ReOrgTests.swift b/Tests/DarksideTests/ReOrgTests.swift index 4451c16c3..b77722fd6 100644 --- a/Tests/DarksideTests/ReOrgTests.swift +++ b/Tests/DarksideTests/ReOrgTests.swift @@ -44,6 +44,10 @@ class ReOrgTests: ZcashTestCase { override func setUp() async throws { try await super.setUp() + mockContainer.mock(type: CheckpointSource.self, isSingleton: true) { _ in + return DarksideMainnetCheckpointSource() + } + self.coordinator = try await TestCoordinator( container: mockContainer, walletBirthday: self.birthday, diff --git a/Tests/DarksideTests/ShieldFundsTests.swift b/Tests/DarksideTests/ShieldFundsTests.swift index 6b9f9a06e..860953aae 100644 --- a/Tests/DarksideTests/ShieldFundsTests.swift +++ b/Tests/DarksideTests/ShieldFundsTests.swift @@ -25,6 +25,10 @@ class ShieldFundsTests: ZcashTestCase { override func setUp() async throws { try await super.setUp() + mockContainer.mock(type: CheckpointSource.self, isSingleton: true) { _ in + return DarksideMainnetCheckpointSource() + } + self.coordinator = try await TestCoordinator( container: mockContainer, walletBirthday: birthday, diff --git a/Tests/DarksideTests/SynchronizerDarksideTests.swift b/Tests/DarksideTests/SynchronizerDarksideTests.swift index 381d8d06b..d69f04aec 100644 --- a/Tests/DarksideTests/SynchronizerDarksideTests.swift +++ b/Tests/DarksideTests/SynchronizerDarksideTests.swift @@ -30,6 +30,11 @@ class SynchronizerDarksideTests: ZcashTestCase { override func setUp() async throws { try await super.setUp() + + mockContainer.mock(type: CheckpointSource.self, isSingleton: true) { _ in + return DarksideMainnetCheckpointSource() + } + let idGenerator = MockSyncSessionIDGenerator(ids: [.deadbeef]) mockContainer.mock(type: SyncSessionIDGenerator.self, isSingleton: false) { _ in idGenerator } self.idGenerator = idGenerator diff --git a/Tests/DarksideTests/SynchronizerTests.swift b/Tests/DarksideTests/SynchronizerTests.swift index 73990e1aa..33df28e1d 100644 --- a/Tests/DarksideTests/SynchronizerTests.swift +++ b/Tests/DarksideTests/SynchronizerTests.swift @@ -26,7 +26,11 @@ final class SynchronizerTests: ZcashTestCase { override func setUp() async throws { try await super.setUp() - + + mockContainer.mock(type: CheckpointSource.self, isSingleton: true) { _ in + return DarksideMainnetCheckpointSource() + } + // don't use an exact birthday, users never do. self.coordinator = try await TestCoordinator( container: mockContainer, diff --git a/Tests/DarksideTests/Z2TReceiveTests.swift b/Tests/DarksideTests/Z2TReceiveTests.swift index cdc5982b1..5f91df810 100644 --- a/Tests/DarksideTests/Z2TReceiveTests.swift +++ b/Tests/DarksideTests/Z2TReceiveTests.swift @@ -28,6 +28,10 @@ class Z2TReceiveTests: ZcashTestCase { override func setUp() async throws { try await super.setUp() + mockContainer.mock(type: CheckpointSource.self, isSingleton: true) { _ in + return DarksideMainnetCheckpointSource() + } + self.coordinator = try await TestCoordinator( container: mockContainer, walletBirthday: birthday, diff --git a/Tests/TestUtils/DarksideMainnetCheckpointSource.swift b/Tests/TestUtils/DarksideMainnetCheckpointSource.swift new file mode 100644 index 000000000..808a27694 --- /dev/null +++ b/Tests/TestUtils/DarksideMainnetCheckpointSource.swift @@ -0,0 +1,35 @@ +// +// TestingCheckpoints.swift +// +// +// Created by Francisco Gindre on 2023-10-31. +// + +import Foundation +@testable import ZcashLightClientKit + +struct DarksideMainnetCheckpointSource: CheckpointSource { + private let treeState = Checkpoint( + height: 663150, + hash: "0000000002fd3be4c24c437bd22620901617125ec2a3a6c902ec9a6c06f734fc", + time: 1576821833, + saplingTree: "01ec6278a1bed9e1b080fd60ef50eb17411645e3746ff129283712bc4757ecc833001001b4e1d4a26ac4a2810b57a14f4ffb69395f55dde5674ecd2462af96f9126e054701a36afb68534f640938bdffd80dfcb3f4d5e232488abbf67d049b33a761e7ed6901a16e35205fb7fe626a9b13fc43e1d2b98a9c241f99f93d5e93a735454073025401f5b9bcbf3d0e3c83f95ee79299e8aeadf30af07717bda15ffb7a3d00243b58570001fa6d4c2390e205f81d86b85ace0b48f3ce0afb78eeef3e14c70bcfd7c5f0191c0000011bc9521263584de20822f9483e7edb5af54150c4823c775b2efc6a1eded9625501a6030f8d4b588681eddb66cad63f09c5c7519db49500fc56ebd481ce5e903c22000163f4eec5a2fe00a5f45e71e1542ff01e937d2210c99f03addcce5314a5278b2d0163ab01f46a3bb6ea46f5a19d5bdd59eb3f81e19cfa6d10ab0fd5566c7a16992601fa6980c053d84f809b6abcf35690f03a11f87b28e3240828e32e3f57af41e54e01319312241b0031e3a255b0d708750b4cb3f3fe79e3503fe488cc8db1dd00753801754bb593ea42d231a7ddf367640f09bbf59dc00f2c1d2003cc340e0c016b5b13", + orchardTree: nil + ) + + var network: NetworkType { + DarksideWalletDNetwork().networkType + } + + var saplingActivation: Checkpoint { + treeState + } + + func latestKnownCheckpoint() -> Checkpoint { + treeState + } + + func birthday(for height: BlockHeight) -> Checkpoint { + treeState + } +}