Replace use of `Checkpoint.birthday(with:network)` with CheckpointSource

This commit is contained in:
Francisco Gindre 2023-10-30 18:42:02 -03:00
parent 4ed74da7f9
commit 6bf8dc7e55
No known key found for this signature in database
GPG Key ID: 6B61CD8DAA2862B4
5 changed files with 18 additions and 8 deletions

View File

@ -281,7 +281,7 @@ public class Initializer {
self.storage = container.resolve(CompactBlockRepository.self)
self.blockDownloaderService = container.resolve(BlockDownloaderService.self)
self.network = network
self.walletBirthday = Checkpoint.birthday(with: 0, network: network).height
self.walletBirthday = container.resolve(CheckpointSource.self).saplingActivation.height
self.urlsParsingError = urlsParsingError
self.logger = container.resolve(Logger.self)
}
@ -416,7 +416,9 @@ public class Initializer {
return .seedRequired
}
let checkpoint = Checkpoint.birthday(with: walletBirthday, network: network)
let checkpointSource = container.resolve(CheckpointSource.self)
let checkpoint = checkpointSource.birthday(for: walletBirthday)
self.walletBirthday = checkpoint.height

View File

@ -17,6 +17,10 @@ enum Dependencies {
loggingPolicy: Initializer.LoggingPolicy = .default(.debug),
enableBackendTracing: Bool = false
) {
container.register(type: CheckpointSource.self, isSingleton: true) { _ in
return CheckpointSourceFactory.fromBundle(for: networkType)
}
container.register(type: Logger.self, isSingleton: true) { _ in
let logger: Logger
switch loggingPolicy {

View File

@ -97,8 +97,9 @@ class ReOrgTests: ZcashTestCase {
let mockLatestHeight = BlockHeight(663200)
let targetLatestHeight = BlockHeight(663202)
let reOrgHeight = BlockHeight(663195)
let walletBirthday = Checkpoint.birthday(with: 663150, network: network).height
let checkpointSource = CheckpointSourceFactory.fromBundle(for: network.networkType)
let walletBirthday = checkpointSource.birthday(for: 663150).height
try await basicReOrgTest(
baseDataset: .beforeReOrg,
reorgDataset: .afterSmallReorg,
@ -113,8 +114,9 @@ class ReOrgTests: ZcashTestCase {
let mockLatestHeight = BlockHeight(663200)
let targetLatestHeight = BlockHeight(663250)
let reOrgHeight = BlockHeight(663180)
let walletBirthday = Checkpoint.birthday(with: BlockHeight(663150), network: network).height
let checkpointSource = CheckpointSourceFactory.fromBundle(for: network.networkType)
let walletBirthday = checkpointSource.birthday(for: 663150).height
try await basicReOrgTest(
baseDataset: .beforeReOrg,
reorgDataset: .afterLargeReorg,

View File

@ -52,7 +52,8 @@ class TransactionEnhancementTests: ZcashTestCase {
waitExpectation = XCTestExpectation(description: "\(self.description) waitExpectation")
let birthday = Checkpoint.birthday(with: walletBirthday, network: network)
let checkpointSource = CheckpointSourceFactory.fromBundle(for: network.networkType)
let birthday = checkpointSource.birthday(for: walletBirthday)
let pathProvider = DefaultResourceProvider(network: network)
processorConfig = CompactBlockProcessor.Configuration(

View File

@ -107,7 +107,8 @@ class ZcashRustBackendTests: XCTestCase {
let initResult = try await rustBackend.initDataDb(seed: seed)
XCTAssertEqual(initResult, .success)
let treeState = Checkpoint.birthday(with: 1234567, network: ZcashMainnet()).treeState()
let checkpointSource = CheckpointSourceFactory.fromBundle(for: .mainnet)
let treeState = checkpointSource.birthday(for: 1234567).treeState()
let usk = try await rustBackend.createAccount(seed: seed, treeState: treeState, recoverUntil: nil)
XCTAssertEqual(usk.account, 0)