Update Rust dependencies with account birthdays and scan progress
The previous FFI repo revisions no longer exist; commits between
87faf91096
and here will not build.
Update Rust dependencies with account birthdays and scan progress
- fixes for SampleApp
This commit is contained in:
parent
e389af4c60
commit
e7621204e5
|
@ -158,7 +158,7 @@
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/zcash-hackworks/zcash-light-client-ffi",
|
"location" : "https://github.com/zcash-hackworks/zcash-light-client-ffi",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "6a53c9e32520b46f8c70597e27b335105fabfc21"
|
"revision" : "1411d9a839a62523997dae113150b2beccd6b3fc"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -45,7 +45,6 @@ class SendViewController: UIViewController {
|
||||||
|
|
||||||
closureSynchronizer.prepare(
|
closureSynchronizer.prepare(
|
||||||
with: DemoAppConfig.defaultSeed,
|
with: DemoAppConfig.defaultSeed,
|
||||||
viewingKeys: [AppDelegate.shared.sharedViewingKey],
|
|
||||||
walletBirthday: DemoAppConfig.defaultBirthdayHeight
|
walletBirthday: DemoAppConfig.defaultBirthdayHeight
|
||||||
) { result in
|
) { result in
|
||||||
loggerProxy.debug("Prepare result: \(result)")
|
loggerProxy.debug("Prepare result: \(result)")
|
||||||
|
|
|
@ -67,13 +67,8 @@ class SyncBlocksListViewController: UIViewController {
|
||||||
case .unprepared, .upToDate, .error(ZcashError.synchronizerDisconnected), .error:
|
case .unprepared, .upToDate, .error(ZcashError.synchronizerDisconnected), .error:
|
||||||
do {
|
do {
|
||||||
if syncStatus == .unprepared {
|
if syncStatus == .unprepared {
|
||||||
let derivationTool = DerivationTool(networkType: kZcashNetwork.networkType)
|
|
||||||
let spendingKey = try derivationTool.deriveUnifiedSpendingKey(seed: synchronizerData.seed, accountIndex: 0)
|
|
||||||
let viewingKey = try derivationTool.deriveUnifiedFullViewingKey(from: spendingKey)
|
|
||||||
|
|
||||||
_ = try! await synchronizer.prepare(
|
_ = try! await synchronizer.prepare(
|
||||||
with: synchronizerData.seed,
|
with: synchronizerData.seed,
|
||||||
viewingKeys: [viewingKey],
|
|
||||||
walletBirthday: synchronizerData.birthday
|
walletBirthday: synchronizerData.birthday
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,7 +153,6 @@ class SyncBlocksViewController: UIViewController {
|
||||||
do {
|
do {
|
||||||
_ = try await synchronizer.prepare(
|
_ = try await synchronizer.prepare(
|
||||||
with: DemoAppConfig.defaultSeed,
|
with: DemoAppConfig.defaultSeed,
|
||||||
viewingKeys: [AppDelegate.shared.sharedViewingKey],
|
|
||||||
walletBirthday: DemoAppConfig.defaultBirthdayHeight
|
walletBirthday: DemoAppConfig.defaultBirthdayHeight
|
||||||
)
|
)
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
@ -113,7 +113,7 @@
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/zcash-hackworks/zcash-light-client-ffi",
|
"location" : "https://github.com/zcash-hackworks/zcash-light-client-ffi",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "6a53c9e32520b46f8c70597e27b335105fabfc21"
|
"revision" : "1411d9a839a62523997dae113150b2beccd6b3fc"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -16,7 +16,7 @@ let package = Package(
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.package(url: "https://github.com/grpc/grpc-swift.git", from: "1.14.0"),
|
.package(url: "https://github.com/grpc/grpc-swift.git", from: "1.14.0"),
|
||||||
.package(url: "https://github.com/stephencelis/SQLite.swift.git", from: "0.14.1"),
|
.package(url: "https://github.com/stephencelis/SQLite.swift.git", from: "0.14.1"),
|
||||||
.package(url: "https://github.com/zcash-hackworks/zcash-light-client-ffi", revision: "6a53c9e32520b46f8c70597e27b335105fabfc21")
|
.package(url: "https://github.com/zcash-hackworks/zcash-light-client-ffi", revision: "1411d9a839a62523997dae113150b2beccd6b3fc")
|
||||||
],
|
],
|
||||||
targets: [
|
targets: [
|
||||||
.target(
|
.target(
|
||||||
|
|
|
@ -107,8 +107,8 @@ extension BlockDownloaderServiceImpl: BlockDownloaderService {
|
||||||
try await self.storage.rewind(to: height)
|
try await self.storage.rewind(to: height)
|
||||||
}
|
}
|
||||||
|
|
||||||
func lastDownloadedBlockHeight() async -> BlockHeight {
|
func lastDownloadedBlockHeight() async throws -> BlockHeight {
|
||||||
await self.storage.latestHeight()
|
try await self.storage.latestHeight()
|
||||||
}
|
}
|
||||||
|
|
||||||
func fetchTransaction(txId: Data) async throws -> ZcashTransaction.Fetched {
|
func fetchTransaction(txId: Data) async throws -> ZcashTransaction.Fetched {
|
||||||
|
|
|
@ -64,8 +64,8 @@ extension FSCompactBlockRepository: CompactBlockRepository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func latestHeight() async -> BlockHeight {
|
func latestHeight() async throws -> BlockHeight {
|
||||||
await metadataStore.latestHeight()
|
try await metadataStore.latestHeight()
|
||||||
}
|
}
|
||||||
|
|
||||||
func write(blocks: [ZcashCompactBlock]) async throws {
|
func write(blocks: [ZcashCompactBlock]) async throws {
|
||||||
|
@ -251,7 +251,7 @@ struct FSMetadataStore {
|
||||||
let saveBlocksMeta: ([ZcashCompactBlock]) async throws -> Void
|
let saveBlocksMeta: ([ZcashCompactBlock]) async throws -> Void
|
||||||
let rewindToHeight: (BlockHeight) async throws -> Void
|
let rewindToHeight: (BlockHeight) async throws -> Void
|
||||||
let initFsBlockDbRoot: () async throws -> Void
|
let initFsBlockDbRoot: () async throws -> Void
|
||||||
let latestHeight: () async -> BlockHeight
|
let latestHeight: () async throws -> BlockHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
extension FSMetadataStore {
|
extension FSMetadataStore {
|
||||||
|
@ -268,7 +268,7 @@ extension FSMetadataStore {
|
||||||
} initFsBlockDbRoot: {
|
} initFsBlockDbRoot: {
|
||||||
try await rustBackend.initBlockMetadataDb()
|
try await rustBackend.initBlockMetadataDb()
|
||||||
} latestHeight: {
|
} latestHeight: {
|
||||||
await rustBackend.latestCachedBlockHeight()
|
try await rustBackend.latestCachedBlockHeight()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ public protocol ClosureSynchronizer {
|
||||||
|
|
||||||
func prepare(
|
func prepare(
|
||||||
with seed: [UInt8]?,
|
with seed: [UInt8]?,
|
||||||
viewingKeys: [UnifiedFullViewingKey],
|
|
||||||
walletBirthday: BlockHeight,
|
walletBirthday: BlockHeight,
|
||||||
completion: @escaping (Result<Initializer.InitializationResult, Error>) -> Void
|
completion: @escaping (Result<Initializer.InitializationResult, Error>) -> Void
|
||||||
)
|
)
|
||||||
|
|
|
@ -24,7 +24,6 @@ public protocol CombineSynchronizer {
|
||||||
|
|
||||||
func prepare(
|
func prepare(
|
||||||
with seed: [UInt8]?,
|
with seed: [UInt8]?,
|
||||||
viewingKeys: [UnifiedFullViewingKey],
|
|
||||||
walletBirthday: BlockHeight
|
walletBirthday: BlockHeight
|
||||||
) -> SinglePublisher<Initializer.InitializationResult, Error>
|
) -> SinglePublisher<Initializer.InitializationResult, Error>
|
||||||
|
|
||||||
|
|
|
@ -294,6 +294,22 @@ public enum ZcashError: Equatable, Error {
|
||||||
/// Invalid transaction ID length when calling ZcashRustBackend.getMemo
|
/// Invalid transaction ID length when calling ZcashRustBackend.getMemo
|
||||||
/// ZRUST0050
|
/// ZRUST0050
|
||||||
case rustGetMemoInvalidTxIdLength
|
case rustGetMemoInvalidTxIdLength
|
||||||
|
/// Error from rust layer when calling ZcashRustBackend.getScanProgress
|
||||||
|
/// - `rustError` contains error generated by the rust layer.
|
||||||
|
/// ZRUST0051
|
||||||
|
case rustGetScanProgress(_ rustError: String)
|
||||||
|
/// Error from rust layer when calling ZcashRustBackend.fullyScannedHeight
|
||||||
|
/// - `rustError` contains error generated by the rust layer.
|
||||||
|
/// ZRUST0052
|
||||||
|
case rustFullyScannedHeight(_ rustError: String)
|
||||||
|
/// Error from rust layer when calling ZcashRustBackend.maxScannedHeight
|
||||||
|
/// - `rustError` contains error generated by the rust layer.
|
||||||
|
/// ZRUST0053
|
||||||
|
case rustMaxScannedHeight(_ rustError: String)
|
||||||
|
/// Error from rust layer when calling ZcashRustBackend.latestCachedBlockHeight
|
||||||
|
/// - `rustError` contains error generated by the rust layer.
|
||||||
|
/// ZRUST0054
|
||||||
|
case rustLatestCachedBlockHeight(_ rustError: String)
|
||||||
/// SQLite query failed when fetching all accounts from the database.
|
/// SQLite query failed when fetching all accounts from the database.
|
||||||
/// - `sqliteError` is error produced by SQLite library.
|
/// - `sqliteError` is error produced by SQLite library.
|
||||||
/// ZADAO0001
|
/// ZADAO0001
|
||||||
|
@ -628,6 +644,10 @@ public enum ZcashError: Equatable, Error {
|
||||||
case .rustUpdateChainTip: return "Error from rust layer when calling ZcashRustBackend.updateChainTip"
|
case .rustUpdateChainTip: return "Error from rust layer when calling ZcashRustBackend.updateChainTip"
|
||||||
case .rustSuggestScanRanges: return "Error from rust layer when calling ZcashRustBackend.suggestScanRanges"
|
case .rustSuggestScanRanges: return "Error from rust layer when calling ZcashRustBackend.suggestScanRanges"
|
||||||
case .rustGetMemoInvalidTxIdLength: return "txId must be 32 bytes"
|
case .rustGetMemoInvalidTxIdLength: return "txId must be 32 bytes"
|
||||||
|
case .rustGetScanProgress: return "Error from rust layer when calling ZcashRustBackend.getScanProgress"
|
||||||
|
case .rustFullyScannedHeight: return "Error from rust layer when calling ZcashRustBackend.fullyScannedHeight"
|
||||||
|
case .rustMaxScannedHeight: return "Error from rust layer when calling ZcashRustBackend.maxScannedHeight"
|
||||||
|
case .rustLatestCachedBlockHeight: return "Error from rust layer when calling ZcashRustBackend.latestCachedBlockHeight"
|
||||||
case .accountDAOGetAll: return "SQLite query failed when fetching all accounts from the database."
|
case .accountDAOGetAll: return "SQLite query failed when fetching all accounts from the database."
|
||||||
case .accountDAOGetAllCantDecode: return "Fetched accounts from SQLite but can't decode them."
|
case .accountDAOGetAllCantDecode: return "Fetched accounts from SQLite but can't decode them."
|
||||||
case .accountDAOFindBy: return "SQLite query failed when seaching for accounts in the database."
|
case .accountDAOFindBy: return "SQLite query failed when seaching for accounts in the database."
|
||||||
|
@ -791,6 +811,10 @@ public enum ZcashError: Equatable, Error {
|
||||||
case .rustUpdateChainTip: return .rustUpdateChainTip
|
case .rustUpdateChainTip: return .rustUpdateChainTip
|
||||||
case .rustSuggestScanRanges: return .rustSuggestScanRanges
|
case .rustSuggestScanRanges: return .rustSuggestScanRanges
|
||||||
case .rustGetMemoInvalidTxIdLength: return .rustGetMemoInvalidTxIdLength
|
case .rustGetMemoInvalidTxIdLength: return .rustGetMemoInvalidTxIdLength
|
||||||
|
case .rustGetScanProgress: return .rustGetScanProgress
|
||||||
|
case .rustFullyScannedHeight: return .rustFullyScannedHeight
|
||||||
|
case .rustMaxScannedHeight: return .rustMaxScannedHeight
|
||||||
|
case .rustLatestCachedBlockHeight: return .rustLatestCachedBlockHeight
|
||||||
case .accountDAOGetAll: return .accountDAOGetAll
|
case .accountDAOGetAll: return .accountDAOGetAll
|
||||||
case .accountDAOGetAllCantDecode: return .accountDAOGetAllCantDecode
|
case .accountDAOGetAllCantDecode: return .accountDAOGetAllCantDecode
|
||||||
case .accountDAOFindBy: return .accountDAOFindBy
|
case .accountDAOFindBy: return .accountDAOFindBy
|
||||||
|
|
|
@ -163,6 +163,14 @@ public enum ZcashErrorCode: String {
|
||||||
case rustSuggestScanRanges = "ZRUST0049"
|
case rustSuggestScanRanges = "ZRUST0049"
|
||||||
/// Invalid transaction ID length when calling ZcashRustBackend.getMemo
|
/// Invalid transaction ID length when calling ZcashRustBackend.getMemo
|
||||||
case rustGetMemoInvalidTxIdLength = "ZRUST0050"
|
case rustGetMemoInvalidTxIdLength = "ZRUST0050"
|
||||||
|
/// Error from rust layer when calling ZcashRustBackend.getScanProgress
|
||||||
|
case rustGetScanProgress = "ZRUST0051"
|
||||||
|
/// Error from rust layer when calling ZcashRustBackend.fullyScannedHeight
|
||||||
|
case rustFullyScannedHeight = "ZRUST0052"
|
||||||
|
/// Error from rust layer when calling ZcashRustBackend.maxScannedHeight
|
||||||
|
case rustMaxScannedHeight = "ZRUST0053"
|
||||||
|
/// Error from rust layer when calling ZcashRustBackend.latestCachedBlockHeight
|
||||||
|
case rustLatestCachedBlockHeight = "ZRUST0054"
|
||||||
/// SQLite query failed when fetching all accounts from the database.
|
/// SQLite query failed when fetching all accounts from the database.
|
||||||
case accountDAOGetAll = "ZADAO0001"
|
case accountDAOGetAll = "ZADAO0001"
|
||||||
/// Fetched accounts from SQLite but can't decode them.
|
/// Fetched accounts from SQLite but can't decode them.
|
||||||
|
|
|
@ -409,7 +409,7 @@ public class Initializer {
|
||||||
/// - Parameter seed: ZIP-32 Seed bytes for the wallet that will be initialized
|
/// - Parameter seed: ZIP-32 Seed bytes for the wallet that will be initialized
|
||||||
/// - Throws: `InitializerError.dataDbInitFailed` if the creation of the dataDb fails
|
/// - Throws: `InitializerError.dataDbInitFailed` if the creation of the dataDb fails
|
||||||
/// `InitializerError.accountInitFailed` if the account table can't be initialized.
|
/// `InitializerError.accountInitFailed` if the account table can't be initialized.
|
||||||
func initialize(with seed: [UInt8]?, viewingKeys: [UnifiedFullViewingKey], walletBirthday: BlockHeight) async throws -> InitializationResult {
|
func initialize(with seed: [UInt8]?, walletBirthday: BlockHeight) async throws -> InitializationResult {
|
||||||
try await storage.create()
|
try await storage.create()
|
||||||
|
|
||||||
if case .seedRequired = try await rustBackend.initDataDb(seed: seed) {
|
if case .seedRequired = try await rustBackend.initDataDb(seed: seed) {
|
||||||
|
@ -417,28 +417,10 @@ public class Initializer {
|
||||||
}
|
}
|
||||||
|
|
||||||
let checkpoint = Checkpoint.birthday(with: walletBirthday, network: network)
|
let checkpoint = Checkpoint.birthday(with: walletBirthday, network: network)
|
||||||
do {
|
|
||||||
try await rustBackend.initBlocksTable(
|
|
||||||
height: Int32(checkpoint.height),
|
|
||||||
hash: checkpoint.hash,
|
|
||||||
time: checkpoint.time,
|
|
||||||
saplingTree: checkpoint.saplingTree
|
|
||||||
)
|
|
||||||
} catch ZcashError.rustInitBlocksTableDataDbNotEmpty {
|
|
||||||
// this is fine
|
|
||||||
} catch {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
|
|
||||||
self.walletBirthday = checkpoint.height
|
self.walletBirthday = checkpoint.height
|
||||||
|
|
||||||
do {
|
// TODO: Initialize accounts if desired.
|
||||||
try await rustBackend.initAccountsTable(ufvks: viewingKeys)
|
|
||||||
} catch ZcashError.rustInitAccountsTableDataDbNotEmpty {
|
|
||||||
// this is fine
|
|
||||||
} catch {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
|
|
||||||
return .success
|
return .success
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,18 @@ extension Checkpoint: Decodable {
|
||||||
}
|
}
|
||||||
return height
|
return height
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func treeState() -> TreeState {
|
||||||
|
var ret = TreeState()
|
||||||
|
ret.height = UInt64(height)
|
||||||
|
ret.hash = hash
|
||||||
|
ret.time = time
|
||||||
|
ret.saplingTree = saplingTree
|
||||||
|
if let tree = orchardTree {
|
||||||
|
ret.orchardTree = tree
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public extension BlockHeight {
|
public extension BlockHeight {
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
//
|
||||||
|
// ScanProgress.swift
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Jack Grigg on 06/09/2023.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
struct ScanProgress {
|
||||||
|
let numerator: UInt64
|
||||||
|
let denominator: UInt64
|
||||||
|
}
|
|
@ -15,7 +15,7 @@ protocol CompactBlockRepository {
|
||||||
/**
|
/**
|
||||||
Gets the height of the highest block that is currently stored.
|
Gets the height of the highest block that is currently stored.
|
||||||
*/
|
*/
|
||||||
func latestHeight() async -> BlockHeight
|
func latestHeight() async throws -> BlockHeight
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Write the given blocks to this store, which may be anything from an in-memory cache to a DB.
|
Write the given blocks to this store, which may be anything from an in-memory cache to a DB.
|
||||||
|
|
|
@ -47,12 +47,15 @@ actor ZcashRustBackend: ZcashRustBackendWelding {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createAccount(seed: [UInt8]) async throws -> UnifiedSpendingKey {
|
func createAccount(seed: [UInt8], treeState: [UInt8], recoverUntil: UInt32?) async throws -> UnifiedSpendingKey {
|
||||||
let ffiBinaryKeyPtr = zcashlc_create_account(
|
let ffiBinaryKeyPtr = zcashlc_create_account(
|
||||||
dbData.0,
|
dbData.0,
|
||||||
dbData.1,
|
dbData.1,
|
||||||
seed,
|
seed,
|
||||||
UInt(seed.count),
|
UInt(seed.count),
|
||||||
|
treeState,
|
||||||
|
UInt(treeState.count),
|
||||||
|
recoverUntil != nil ? Int64(recoverUntil!) : -1,
|
||||||
networkType.networkId
|
networkType.networkId
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -278,57 +281,6 @@ actor ZcashRustBackend: ZcashRustBackendWelding {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func initAccountsTable(ufvks: [UnifiedFullViewingKey]) async throws {
|
|
||||||
var ffiUfvks: [FFIEncodedKey] = []
|
|
||||||
for ufvk in ufvks {
|
|
||||||
guard !ufvk.encoding.containsCStringNullBytesBeforeStringEnding() else {
|
|
||||||
throw ZcashError.rustInitAccountsTableViewingKeyCotainsNullBytes
|
|
||||||
}
|
|
||||||
|
|
||||||
guard self.keyDeriving.isValidUnifiedFullViewingKey(ufvk.encoding) else {
|
|
||||||
throw ZcashError.rustInitAccountsTableViewingKeyIsInvalid
|
|
||||||
}
|
|
||||||
|
|
||||||
let ufvkCStr = [CChar](String(ufvk.encoding).utf8CString)
|
|
||||||
|
|
||||||
let ufvkPtr = UnsafeMutablePointer<CChar>.allocate(capacity: ufvkCStr.count)
|
|
||||||
ufvkPtr.initialize(from: ufvkCStr, count: ufvkCStr.count)
|
|
||||||
|
|
||||||
ffiUfvks.append(
|
|
||||||
FFIEncodedKey(account_id: ufvk.account, encoding: ufvkPtr)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
var contiguousUVKs = ContiguousArray(ffiUfvks)
|
|
||||||
|
|
||||||
var result = false
|
|
||||||
|
|
||||||
contiguousUVKs.withContiguousMutableStorageIfAvailable { ufvksPtr in
|
|
||||||
result = zcashlc_init_accounts_table_with_keys(
|
|
||||||
dbData.0,
|
|
||||||
dbData.1,
|
|
||||||
ufvksPtr.baseAddress,
|
|
||||||
UInt(ufvks.count),
|
|
||||||
networkType.networkId
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
defer {
|
|
||||||
for ufvk in ffiUfvks {
|
|
||||||
ufvk.encoding.deallocate()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
guard result else {
|
|
||||||
let message = lastErrorMessage(fallback: "`initAccountsTable` failed with unknown error")
|
|
||||||
if message.isDbNotEmptyErrorMessage() {
|
|
||||||
throw ZcashError.rustInitAccountsTableDataDbNotEmpty
|
|
||||||
} else {
|
|
||||||
throw ZcashError.rustInitAccountsTable(message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func initBlockMetadataDb() async throws {
|
func initBlockMetadataDb() async throws {
|
||||||
let result = zcashlc_init_block_metadata_db(fsBlockDbRoot.0, fsBlockDbRoot.1)
|
let result = zcashlc_init_block_metadata_db(fsBlockDbRoot.0, fsBlockDbRoot.1)
|
||||||
|
|
||||||
|
@ -394,43 +346,17 @@ actor ZcashRustBackend: ZcashRustBackendWelding {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func initBlocksTable(
|
func latestCachedBlockHeight() async throws -> BlockHeight {
|
||||||
height: Int32,
|
let height = zcashlc_latest_cached_block_height(fsBlockDbRoot.0, fsBlockDbRoot.1)
|
||||||
hash: String,
|
|
||||||
time: UInt32,
|
|
||||||
saplingTree: String
|
|
||||||
) async throws {
|
|
||||||
guard !hash.containsCStringNullBytesBeforeStringEnding() else {
|
|
||||||
throw ZcashError.rustInitBlocksTableHashContainsNullBytes
|
|
||||||
}
|
|
||||||
|
|
||||||
guard !saplingTree.containsCStringNullBytesBeforeStringEnding() else {
|
if height >= 0 {
|
||||||
throw ZcashError.rustInitBlocksTableSaplingTreeContainsNullBytes
|
return BlockHeight(height)
|
||||||
}
|
} else if height == -1 {
|
||||||
|
return BlockHeight.empty()
|
||||||
let result = zcashlc_init_blocks_table(
|
|
||||||
dbData.0,
|
|
||||||
dbData.1,
|
|
||||||
height,
|
|
||||||
[CChar](hash.utf8CString),
|
|
||||||
time,
|
|
||||||
[CChar](saplingTree.utf8CString),
|
|
||||||
networkType.networkId
|
|
||||||
)
|
|
||||||
|
|
||||||
guard result != 0 else {
|
|
||||||
let message = lastErrorMessage(fallback: "`initBlocksTable` failed with unknown error")
|
|
||||||
if message.isDbNotEmptyErrorMessage() {
|
|
||||||
throw ZcashError.rustInitBlocksTableDataDbNotEmpty
|
|
||||||
} else {
|
} else {
|
||||||
throw ZcashError.rustInitBlocksTable(message)
|
throw ZcashError.rustLatestCachedBlockHeight(lastErrorMessage(fallback: "`latestCachedBlockHeight` failed with unknown error"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func latestCachedBlockHeight() async -> BlockHeight {
|
|
||||||
return BlockHeight(zcashlc_latest_cached_block_height(fsBlockDbRoot.0, fsBlockDbRoot.1))
|
|
||||||
}
|
|
||||||
|
|
||||||
func listTransparentReceivers(account: Int32) async throws -> [TransparentAddress] {
|
func listTransparentReceivers(account: Int32) async throws -> [TransparentAddress] {
|
||||||
let encodedKeysPtr = zcashlc_list_transparent_receivers(
|
let encodedKeysPtr = zcashlc_list_transparent_receivers(
|
||||||
|
@ -565,6 +491,45 @@ actor ZcashRustBackend: ZcashRustBackendWelding {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func fullyScannedHeight() async throws -> BlockHeight? {
|
||||||
|
let height = zcashlc_fully_scanned_height(dbData.0, dbData.1, networkType.networkId)
|
||||||
|
|
||||||
|
if height >= 0 {
|
||||||
|
return BlockHeight(height)
|
||||||
|
} else if height == -1 {
|
||||||
|
return nil
|
||||||
|
} else {
|
||||||
|
throw ZcashError.rustFullyScannedHeight(lastErrorMessage(fallback: "`fullyScannedHeight` failed with unknown error"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func maxScannedHeight() async throws -> BlockHeight? {
|
||||||
|
let height = zcashlc_max_scanned_height(dbData.0, dbData.1, networkType.networkId)
|
||||||
|
|
||||||
|
if height >= 0 {
|
||||||
|
return BlockHeight(height)
|
||||||
|
} else if height == -1 {
|
||||||
|
return nil
|
||||||
|
} else {
|
||||||
|
throw ZcashError.rustMaxScannedHeight(lastErrorMessage(fallback: "`maxScannedHeight` failed with unknown error"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getScanProgress() async throws -> ScanProgress? {
|
||||||
|
let result = zcashlc_get_scan_progress(dbData.0, dbData.1, networkType.networkId)
|
||||||
|
|
||||||
|
if result.denominator == 0 {
|
||||||
|
switch result.numerator {
|
||||||
|
case 0:
|
||||||
|
return nil;
|
||||||
|
default:
|
||||||
|
throw ZcashError.rustGetScanProgress(lastErrorMessage(fallback: "`getScanProgress` failed with unknown error"))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return ScanProgress(numerator: result.numerator, denominator: result.denominator)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func suggestScanRanges() async throws -> [ScanRange] {
|
func suggestScanRanges() async throws -> [ScanRange] {
|
||||||
let scanRangesPtr = zcashlc_suggest_scan_ranges(dbData.0, dbData.1, networkType.networkId)
|
let scanRangesPtr = zcashlc_suggest_scan_ranges(dbData.0, dbData.1, networkType.networkId)
|
||||||
|
|
||||||
|
|
|
@ -35,9 +35,11 @@ protocol ZcashRustBackendWelding {
|
||||||
/// have been received by the currently-available account (in order to enable
|
/// have been received by the currently-available account (in order to enable
|
||||||
/// automated account recovery).
|
/// automated account recovery).
|
||||||
/// - parameter seed: byte array of the zip32 seed
|
/// - parameter seed: byte array of the zip32 seed
|
||||||
|
/// - parameter treeState: byte array containing the TreeState Protobuf object for the height prior to the account birthday
|
||||||
|
/// - parameter recoverUntil: the fully-scanned height up to which the account will be treated as "being recovered"
|
||||||
/// - Returns: The `UnifiedSpendingKey` structs for the number of accounts created
|
/// - Returns: The `UnifiedSpendingKey` structs for the number of accounts created
|
||||||
/// - Throws: `rustCreateAccount`.
|
/// - Throws: `rustCreateAccount`.
|
||||||
func createAccount(seed: [UInt8]) async throws -> UnifiedSpendingKey
|
func createAccount(seed: [UInt8], treeState: [UInt8], recoverUntil: UInt32?) async throws -> UnifiedSpendingKey
|
||||||
|
|
||||||
/// Creates a transaction to the given address from the given account
|
/// Creates a transaction to the given address from the given account
|
||||||
/// - Parameter usk: `UnifiedSpendingKey` for the account that controls the funds to be spent.
|
/// - Parameter usk: `UnifiedSpendingKey` for the account that controls the funds to be spent.
|
||||||
|
@ -101,14 +103,6 @@ protocol ZcashRustBackendWelding {
|
||||||
/// - `rustGetTransparentBalance` if rust layer returns error.
|
/// - `rustGetTransparentBalance` if rust layer returns error.
|
||||||
func getTransparentBalance(account: Int32) async throws -> Int64
|
func getTransparentBalance(account: Int32) async throws -> Int64
|
||||||
|
|
||||||
/// Initialize the accounts table from a set of unified full viewing keys.
|
|
||||||
/// - Note: this function should only be used when restoring an existing seed phrase. when creating a new wallet, use `createAccount()` instead.
|
|
||||||
/// - Parameter ufvks: an array of UnifiedFullViewingKeys
|
|
||||||
/// - Throws:
|
|
||||||
/// - `rustInitAccountsTableViewingKeyCotainsNullBytes` if any of the key in `ufvks` contains null bytes before end.
|
|
||||||
/// - `rustInitAccountsTableViewingKeyIsInvalid` if any of the key in `ufvks` isn't valid.
|
|
||||||
func initAccountsTable(ufvks: [UnifiedFullViewingKey]) async throws
|
|
||||||
|
|
||||||
/// Initializes the data db. This will performs any migrations needed on the sqlite file
|
/// Initializes the data db. This will performs any migrations needed on the sqlite file
|
||||||
/// provided. Some migrations might need that callers provide the seed bytes.
|
/// provided. Some migrations might need that callers provide the seed bytes.
|
||||||
/// - Parameter seed: ZIP-32 compliant seed bytes for this wallet
|
/// - Parameter seed: ZIP-32 compliant seed bytes for this wallet
|
||||||
|
@ -118,23 +112,6 @@ protocol ZcashRustBackendWelding {
|
||||||
/// Throws `rustInitDataDb` if rust layer returns error.
|
/// Throws `rustInitDataDb` if rust layer returns error.
|
||||||
func initDataDb(seed: [UInt8]?) async throws -> DbInitResult
|
func initDataDb(seed: [UInt8]?) async throws -> DbInitResult
|
||||||
|
|
||||||
/// Initialize the blocks table from a given checkpoint (heigh, hash, time, saplingTree and networkType).
|
|
||||||
/// - parameter height: represents the block height of the given checkpoint
|
|
||||||
/// - parameter hash: hash of the merkle tree
|
|
||||||
/// - parameter time: in milliseconds from reference
|
|
||||||
/// - parameter saplingTree: hash of the sapling tree
|
|
||||||
/// - Throws:
|
|
||||||
/// - `rustInitBlocksTableHashContainsNullBytes` if `hash` contains null bytes before end.
|
|
||||||
/// - `rustInitBlocksTableSaplingTreeContainsNullBytes` if `saplingTree` contains null bytes before end.
|
|
||||||
/// - `rustInitBlocksTableDataDbNotEmpty` if data DB is not empty.
|
|
||||||
/// - `rustInitBlocksTable` if rust layer returns error.
|
|
||||||
func initBlocksTable(
|
|
||||||
height: Int32,
|
|
||||||
hash: String,
|
|
||||||
time: UInt32,
|
|
||||||
saplingTree: String
|
|
||||||
) async throws
|
|
||||||
|
|
||||||
/// Returns a list of the transparent receivers for the diversified unified addresses that have
|
/// Returns a list of the transparent receivers for the diversified unified addresses that have
|
||||||
/// been allocated for the provided account.
|
/// been allocated for the provided account.
|
||||||
/// - parameter account: index of the given account
|
/// - parameter account: index of the given account
|
||||||
|
@ -166,6 +143,31 @@ protocol ZcashRustBackendWelding {
|
||||||
/// - Throws: `rustRewindCacheToHeight` if rust layer returns error.
|
/// - Throws: `rustRewindCacheToHeight` if rust layer returns error.
|
||||||
func rewindCacheToHeight(height: Int32) async throws
|
func rewindCacheToHeight(height: Int32) async throws
|
||||||
|
|
||||||
|
/// Updates the wallet's view of the blockchain.
|
||||||
|
///
|
||||||
|
/// This method is used to provide the wallet with information about the state of the blockchain,
|
||||||
|
/// and detect any previously scanned data that needs to be re-validated before proceeding with
|
||||||
|
/// scanning. It should be called at wallet startup prior to calling `suggestScanRanges`
|
||||||
|
/// in order to provide the wallet with the information it needs to correctly prioritize scanning
|
||||||
|
/// operations.
|
||||||
|
func updateChainTip(height: Int32) async throws
|
||||||
|
|
||||||
|
/// Returns the height to which the wallet has been fully scanned.
|
||||||
|
///
|
||||||
|
/// This is the height for which the wallet has fully trial-decrypted this and all
|
||||||
|
/// preceding blocks beginning with the wallet's birthday height.
|
||||||
|
func fullyScannedHeight() async throws -> BlockHeight?
|
||||||
|
|
||||||
|
/// Returns the maximum height that the wallet has scanned.
|
||||||
|
///
|
||||||
|
/// If the wallet is fully synced, this will be equivalent to `fullyScannedHeight`;
|
||||||
|
/// otherwise the maximal scanned height is likely to be greater than the fully scanned
|
||||||
|
/// height due to the fact that out-of-order scanning can leave gaps.
|
||||||
|
func maxScannedHeight() async throws -> BlockHeight?
|
||||||
|
|
||||||
|
/// Returns the scan progress derived from the current wallet state.
|
||||||
|
func getScanProgress() async throws -> ScanProgress?
|
||||||
|
|
||||||
/// Returns a list of suggested scan ranges based upon the current wallet state.
|
/// Returns a list of suggested scan ranges based upon the current wallet state.
|
||||||
///
|
///
|
||||||
/// This method should only be used in cases where the `CompactBlock` data that will be
|
/// This method should only be used in cases where the `CompactBlock` data that will be
|
||||||
|
@ -242,5 +244,5 @@ protocol ZcashRustBackendWelding {
|
||||||
/// this directory is expected to contain a `/blocks` sub-directory with the blocks stored in the convened filename
|
/// this directory is expected to contain a `/blocks` sub-directory with the blocks stored in the convened filename
|
||||||
/// format `{height}-{hash}-block`. This directory has must be granted both write and read permissions.
|
/// format `{height}-{hash}-block`. This directory has must be granted both write and read permissions.
|
||||||
/// - Returns `BlockHeight` of the latest cached block or `.empty` if no blocks are stored.
|
/// - Returns `BlockHeight` of the latest cached block or `.empty` if no blocks are stored.
|
||||||
func latestCachedBlockHeight() async -> BlockHeight
|
func latestCachedBlockHeight() async throws -> BlockHeight
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,8 +131,7 @@ public protocol Synchronizer: AnyObject {
|
||||||
/// do not already exist). These files can be given a prefix for scenarios where multiple wallets
|
/// do not already exist). These files can be given a prefix for scenarios where multiple wallets
|
||||||
///
|
///
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - seed: ZIP-32 Seed bytes for the wallet that will be initialized.
|
/// - seed: ZIP-32 Seed bytes for the wallet that will be initialized
|
||||||
/// - viewingKeys: Viewing key derived from seed.
|
|
||||||
/// - walletBirthday: Birthday of wallet.
|
/// - walletBirthday: Birthday of wallet.
|
||||||
/// - Throws:
|
/// - Throws:
|
||||||
/// - `aliasAlreadyInUse` if the Alias used to create this instance is already used by other instance.
|
/// - `aliasAlreadyInUse` if the Alias used to create this instance is already used by other instance.
|
||||||
|
@ -142,7 +141,6 @@ public protocol Synchronizer: AnyObject {
|
||||||
/// - Some other `ZcashError` thrown by lower layer of the SDK.
|
/// - Some other `ZcashError` thrown by lower layer of the SDK.
|
||||||
func prepare(
|
func prepare(
|
||||||
with seed: [UInt8]?,
|
with seed: [UInt8]?,
|
||||||
viewingKeys: [UnifiedFullViewingKey],
|
|
||||||
walletBirthday: BlockHeight
|
walletBirthday: BlockHeight
|
||||||
) async throws -> Initializer.InitializationResult
|
) async throws -> Initializer.InitializationResult
|
||||||
|
|
||||||
|
|
|
@ -33,12 +33,11 @@ extension ClosureSDKSynchronizer: ClosureSynchronizer {
|
||||||
|
|
||||||
public func prepare(
|
public func prepare(
|
||||||
with seed: [UInt8]?,
|
with seed: [UInt8]?,
|
||||||
viewingKeys: [UnifiedFullViewingKey],
|
|
||||||
walletBirthday: BlockHeight,
|
walletBirthday: BlockHeight,
|
||||||
completion: @escaping (Result<Initializer.InitializationResult, Error>) -> Void
|
completion: @escaping (Result<Initializer.InitializationResult, Error>) -> Void
|
||||||
) {
|
) {
|
||||||
AsyncToClosureGateway.executeThrowingAction(completion) {
|
AsyncToClosureGateway.executeThrowingAction(completion) {
|
||||||
return try await self.synchronizer.prepare(with: seed, viewingKeys: viewingKeys, walletBirthday: walletBirthday)
|
return try await self.synchronizer.prepare(with: seed, walletBirthday: walletBirthday)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,11 +33,10 @@ extension CombineSDKSynchronizer: CombineSynchronizer {
|
||||||
|
|
||||||
public func prepare(
|
public func prepare(
|
||||||
with seed: [UInt8]?,
|
with seed: [UInt8]?,
|
||||||
viewingKeys: [UnifiedFullViewingKey],
|
|
||||||
walletBirthday: BlockHeight
|
walletBirthday: BlockHeight
|
||||||
) -> SinglePublisher<Initializer.InitializationResult, Error> {
|
) -> SinglePublisher<Initializer.InitializationResult, Error> {
|
||||||
AsyncToCombineGateway.executeThrowingAction() {
|
AsyncToCombineGateway.executeThrowingAction() {
|
||||||
return try await self.synchronizer.prepare(with: seed, viewingKeys: viewingKeys, walletBirthday: walletBirthday)
|
return try await self.synchronizer.prepare(with: seed, walletBirthday: walletBirthday)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,6 @@ public class SDKSynchronizer: Synchronizer {
|
||||||
|
|
||||||
public func prepare(
|
public func prepare(
|
||||||
with seed: [UInt8]?,
|
with seed: [UInt8]?,
|
||||||
viewingKeys: [UnifiedFullViewingKey],
|
|
||||||
walletBirthday: BlockHeight
|
walletBirthday: BlockHeight
|
||||||
) async throws -> Initializer.InitializationResult {
|
) async throws -> Initializer.InitializationResult {
|
||||||
guard await status == .unprepared else { return .success }
|
guard await status == .unprepared else { return .success }
|
||||||
|
@ -138,7 +137,7 @@ public class SDKSynchronizer: Synchronizer {
|
||||||
|
|
||||||
try await utxoRepository.initialise()
|
try await utxoRepository.initialise()
|
||||||
|
|
||||||
if case .seedRequired = try await self.initializer.initialize(with: seed, viewingKeys: viewingKeys, walletBirthday: walletBirthday) {
|
if case .seedRequired = try await self.initializer.initialize(with: seed, walletBirthday: walletBirthday) {
|
||||||
return .seedRequired
|
return .seedRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ class BlockDownloaderTests: XCTestCase {
|
||||||
try await downloader.downloadBlockRange(range)
|
try await downloader.downloadBlockRange(range)
|
||||||
|
|
||||||
// check what was 'stored'
|
// check what was 'stored'
|
||||||
let latestHeight = await self.storage.latestHeight()
|
let latestHeight = try await self.storage.latestHeight()
|
||||||
XCTAssertEqual(latestHeight, upperRange)
|
XCTAssertEqual(latestHeight, upperRange)
|
||||||
|
|
||||||
let resultHeight = try await self.downloader.lastDownloadedBlockHeight()
|
let resultHeight = try await self.downloader.lastDownloadedBlockHeight()
|
||||||
|
|
|
@ -82,9 +82,13 @@ class TransactionEnhancementTests: ZcashTestCase {
|
||||||
let viewingKey = try derivationTool.deriveUnifiedFullViewingKey(from: spendingKey)
|
let viewingKey = try derivationTool.deriveUnifiedFullViewingKey(from: spendingKey)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
try await rustBackend.initAccountsTable(ufvks: [viewingKey])
|
_ = try await rustBackend.createAccount(
|
||||||
|
seed: Environment.seedBytes,
|
||||||
|
treeState: birthday.treeState().serializedData(partial: false).bytes,
|
||||||
|
recoverUntil: nil
|
||||||
|
)
|
||||||
} catch {
|
} catch {
|
||||||
XCTFail("Failed to init accounts table error: \(error)")
|
XCTFail("Failed to create account. Error: \(error)")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,13 +97,6 @@ class TransactionEnhancementTests: ZcashTestCase {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = try await rustBackend.initBlocksTable(
|
|
||||||
height: Int32(birthday.height),
|
|
||||||
hash: birthday.hash,
|
|
||||||
time: birthday.time,
|
|
||||||
saplingTree: birthday.saplingTree
|
|
||||||
)
|
|
||||||
|
|
||||||
let service = DarksideWalletService()
|
let service = DarksideWalletService()
|
||||||
darksideWalletService = service
|
darksideWalletService = service
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ class DownloadTests: ZcashTestCase {
|
||||||
XCTFail("Download failed with error: \(error)")
|
XCTFail("Download failed with error: \(error)")
|
||||||
}
|
}
|
||||||
|
|
||||||
let latestHeight = await storage.latestHeight()
|
let latestHeight = try await storage.latestHeight()
|
||||||
XCTAssertEqual(latestHeight, range.upperBound)
|
XCTAssertEqual(latestHeight, range.upperBound)
|
||||||
|
|
||||||
await compactBlockProcessor.stop()
|
await compactBlockProcessor.stop()
|
||||||
|
|
|
@ -101,17 +101,15 @@ class ClosureSynchronizerOfflineTests: XCTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPrepareSucceed() throws {
|
func testPrepareSucceed() throws {
|
||||||
let mockedViewingKey = data.viewingKey
|
synchronizerMock.prepareWithWalletBirthdayClosure = { receivedSeed, receivedWalletBirthday in
|
||||||
synchronizerMock.prepareWithViewingKeysWalletBirthdayClosure = { receivedSeed, receivedViewingKeys, receivedWalletBirthday in
|
|
||||||
XCTAssertEqual(receivedSeed, self.data.seed)
|
XCTAssertEqual(receivedSeed, self.data.seed)
|
||||||
XCTAssertEqual(receivedViewingKeys, [mockedViewingKey])
|
|
||||||
XCTAssertEqual(receivedWalletBirthday, self.data.birthday)
|
XCTAssertEqual(receivedWalletBirthday, self.data.birthday)
|
||||||
return .success
|
return .success
|
||||||
}
|
}
|
||||||
|
|
||||||
let expectation = XCTestExpectation()
|
let expectation = XCTestExpectation()
|
||||||
|
|
||||||
synchronizer.prepare(with: data.seed, viewingKeys: [mockedViewingKey], walletBirthday: data.birthday) { result in
|
synchronizer.prepare(with: data.seed, walletBirthday: data.birthday) { result in
|
||||||
switch result {
|
switch result {
|
||||||
case let .success(status):
|
case let .success(status):
|
||||||
XCTAssertEqual(status, .success)
|
XCTAssertEqual(status, .success)
|
||||||
|
@ -125,14 +123,13 @@ class ClosureSynchronizerOfflineTests: XCTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPrepareThrowsError() throws {
|
func testPrepareThrowsError() throws {
|
||||||
let mockedViewingKey = data.viewingKey
|
synchronizerMock.prepareWithWalletBirthdayClosure = { _, _ in
|
||||||
synchronizerMock.prepareWithViewingKeysWalletBirthdayClosure = { _, _, _ in
|
|
||||||
throw "Some error"
|
throw "Some error"
|
||||||
}
|
}
|
||||||
|
|
||||||
let expectation = XCTestExpectation()
|
let expectation = XCTestExpectation()
|
||||||
|
|
||||||
synchronizer.prepare(with: data.seed, viewingKeys: [mockedViewingKey], walletBirthday: data.birthday) { result in
|
synchronizer.prepare(with: data.seed, walletBirthday: data.birthday) { result in
|
||||||
switch result {
|
switch result {
|
||||||
case .success:
|
case .success:
|
||||||
XCTFail("Error should be thrown.")
|
XCTFail("Error should be thrown.")
|
||||||
|
|
|
@ -102,16 +102,15 @@ class CombineSynchronizerOfflineTests: XCTestCase {
|
||||||
|
|
||||||
func testPrepareSucceed() throws {
|
func testPrepareSucceed() throws {
|
||||||
let mockedViewingKey = self.data.viewingKey
|
let mockedViewingKey = self.data.viewingKey
|
||||||
synchronizerMock.prepareWithViewingKeysWalletBirthdayClosure = { receivedSeed, receivedViewingKeys, receivedWalletBirthday in
|
synchronizerMock.prepareWithWalletBirthdayClosure = { receivedSeed, receivedWalletBirthday in
|
||||||
XCTAssertEqual(receivedSeed, self.data.seed)
|
XCTAssertEqual(receivedSeed, self.data.seed)
|
||||||
XCTAssertEqual(receivedViewingKeys, [mockedViewingKey])
|
|
||||||
XCTAssertEqual(receivedWalletBirthday, self.data.birthday)
|
XCTAssertEqual(receivedWalletBirthday, self.data.birthday)
|
||||||
return .success
|
return .success
|
||||||
}
|
}
|
||||||
|
|
||||||
let expectation = XCTestExpectation()
|
let expectation = XCTestExpectation()
|
||||||
|
|
||||||
synchronizer.prepare(with: data.seed, viewingKeys: [mockedViewingKey], walletBirthday: data.birthday)
|
synchronizer.prepare(with: data.seed, walletBirthday: data.birthday)
|
||||||
.sink(
|
.sink(
|
||||||
receiveCompletion: { result in
|
receiveCompletion: { result in
|
||||||
switch result {
|
switch result {
|
||||||
|
@ -132,13 +131,13 @@ class CombineSynchronizerOfflineTests: XCTestCase {
|
||||||
|
|
||||||
func testPrepareThrowsError() throws {
|
func testPrepareThrowsError() throws {
|
||||||
let mockedViewingKey = self.data.viewingKey
|
let mockedViewingKey = self.data.viewingKey
|
||||||
synchronizerMock.prepareWithViewingKeysWalletBirthdayClosure = { _, _, _ in
|
synchronizerMock.prepareWithWalletBirthdayClosure = { _, _ in
|
||||||
throw "Some error"
|
throw "Some error"
|
||||||
}
|
}
|
||||||
|
|
||||||
let expectation = XCTestExpectation()
|
let expectation = XCTestExpectation()
|
||||||
|
|
||||||
synchronizer.prepare(with: data.seed, viewingKeys: [mockedViewingKey], walletBirthday: data.birthday)
|
synchronizer.prepare(with: data.seed, walletBirthday: data.birthday)
|
||||||
.sink(
|
.sink(
|
||||||
receiveCompletion: { result in
|
receiveCompletion: { result in
|
||||||
switch result {
|
switch result {
|
||||||
|
|
|
@ -41,7 +41,7 @@ class CompactBlockRepositoryTests: ZcashTestCase {
|
||||||
|
|
||||||
try await compactBlockRepository.create()
|
try await compactBlockRepository.create()
|
||||||
|
|
||||||
let latestHeight = await compactBlockRepository.latestHeight()
|
let latestHeight = try await compactBlockRepository.latestHeight()
|
||||||
XCTAssertEqual(latestHeight, BlockHeight.empty())
|
XCTAssertEqual(latestHeight, BlockHeight.empty())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,14 +60,14 @@ class CompactBlockRepositoryTests: ZcashTestCase {
|
||||||
|
|
||||||
try await compactBlockRepository.create()
|
try await compactBlockRepository.create()
|
||||||
|
|
||||||
let initialHeight = await compactBlockRepository.latestHeight()
|
let initialHeight = try await compactBlockRepository.latestHeight()
|
||||||
let startHeight = self.network.constants.saplingActivationHeight
|
let startHeight = self.network.constants.saplingActivationHeight
|
||||||
let blockCount = Int(1_000)
|
let blockCount = Int(1_000)
|
||||||
let finalHeight = startHeight + blockCount
|
let finalHeight = startHeight + blockCount
|
||||||
|
|
||||||
try await TestDbBuilder.seed(db: compactBlockRepository, with: startHeight...finalHeight)
|
try await TestDbBuilder.seed(db: compactBlockRepository, with: startHeight...finalHeight)
|
||||||
|
|
||||||
let latestHeight = await compactBlockRepository.latestHeight()
|
let latestHeight = try await compactBlockRepository.latestHeight()
|
||||||
XCTAssertNotEqual(initialHeight, latestHeight)
|
XCTAssertNotEqual(initialHeight, latestHeight)
|
||||||
XCTAssertEqual(latestHeight, finalHeight)
|
XCTAssertEqual(latestHeight, finalHeight)
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ class CompactBlockRepositoryTests: ZcashTestCase {
|
||||||
}
|
}
|
||||||
try await compactBlockRepository.write(blocks: [block])
|
try await compactBlockRepository.write(blocks: [block])
|
||||||
|
|
||||||
let result = await compactBlockRepository.latestHeight()
|
let result = try await compactBlockRepository.latestHeight()
|
||||||
XCTAssertEqual(result, expectedHeight)
|
XCTAssertEqual(result, expectedHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ class CompactBlockRepositoryTests: ZcashTestCase {
|
||||||
let rewindHeight = BlockHeight(finalHeight - 233)
|
let rewindHeight = BlockHeight(finalHeight - 233)
|
||||||
|
|
||||||
try await compactBlockRepository.rewind(to: rewindHeight)
|
try await compactBlockRepository.rewind(to: rewindHeight)
|
||||||
let latestHeight = await compactBlockRepository.latestHeight()
|
let latestHeight = try await compactBlockRepository.latestHeight()
|
||||||
XCTAssertEqual(latestHeight, rewindHeight)
|
XCTAssertEqual(latestHeight, rewindHeight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ final class FsBlockStorageTests: ZcashTestCase {
|
||||||
|
|
||||||
try await emptyCache.create()
|
try await emptyCache.create()
|
||||||
|
|
||||||
let latestHeight = await emptyCache.latestHeight()
|
let latestHeight = try await emptyCache.latestHeight()
|
||||||
XCTAssertEqual(latestHeight, .empty())
|
XCTAssertEqual(latestHeight, .empty())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ final class FsBlockStorageTests: ZcashTestCase {
|
||||||
|
|
||||||
try await freshCache.write(blocks: fakeBlocks)
|
try await freshCache.write(blocks: fakeBlocks)
|
||||||
|
|
||||||
let latestHeight = await freshCache.latestHeight()
|
let latestHeight = try await freshCache.latestHeight()
|
||||||
|
|
||||||
XCTAssertEqual(latestHeight, 2000)
|
XCTAssertEqual(latestHeight, 2000)
|
||||||
}
|
}
|
||||||
|
@ -292,12 +292,12 @@ final class FsBlockStorageTests: ZcashTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
try await fsBlockCache.write(blocks: stubBlocks)
|
try await fsBlockCache.write(blocks: stubBlocks)
|
||||||
var latestHeight = await fsBlockCache.latestHeight()
|
var latestHeight = try await fsBlockCache.latestHeight()
|
||||||
XCTAssertEqual(latestHeight, 1010)
|
XCTAssertEqual(latestHeight, 1010)
|
||||||
|
|
||||||
try await fsBlockCache.clear()
|
try await fsBlockCache.clear()
|
||||||
|
|
||||||
latestHeight = await fsBlockCache.latestHeight()
|
latestHeight = try await fsBlockCache.latestHeight()
|
||||||
XCTAssertEqual(latestHeight, .empty())
|
XCTAssertEqual(latestHeight, .empty())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@ final class FsBlockStorageTests: ZcashTestCase {
|
||||||
|
|
||||||
try await realCache.write(blocks: sandblastedBlocks)
|
try await realCache.write(blocks: sandblastedBlocks)
|
||||||
|
|
||||||
let latestHeight = await realCache.latestHeight()
|
let latestHeight = try await realCache.latestHeight()
|
||||||
|
|
||||||
XCTAssertEqual(latestHeight, 19)
|
XCTAssertEqual(latestHeight, 19)
|
||||||
}
|
}
|
||||||
|
@ -390,20 +390,20 @@ final class FsBlockStorageTests: ZcashTestCase {
|
||||||
|
|
||||||
XCTAssertLessThan(timePassed, 0.5)
|
XCTAssertLessThan(timePassed, 0.5)
|
||||||
|
|
||||||
let latestHeight = await realCache.latestHeight()
|
let latestHeight = try await realCache.latestHeight()
|
||||||
|
|
||||||
XCTAssertEqual(latestHeight, 19)
|
XCTAssertEqual(latestHeight, 19)
|
||||||
|
|
||||||
try await realCache.rewind(to: 14)
|
try await realCache.rewind(to: 14)
|
||||||
|
|
||||||
let rewoundHeight = await realCache.latestHeight()
|
let rewoundHeight = try await realCache.latestHeight()
|
||||||
|
|
||||||
XCTAssertEqual(rewoundHeight, 14)
|
XCTAssertEqual(rewoundHeight, 14)
|
||||||
|
|
||||||
let blockSlice = [ZcashCompactBlock](sandblastedBlocks[5...])
|
let blockSlice = [ZcashCompactBlock](sandblastedBlocks[5...])
|
||||||
try await realCache.write(blocks: blockSlice)
|
try await realCache.write(blocks: blockSlice)
|
||||||
|
|
||||||
let newLatestHeight = await realCache.latestHeight()
|
let newLatestHeight = try await realCache.latestHeight()
|
||||||
|
|
||||||
XCTAssertEqual(newLatestHeight, 19)
|
XCTAssertEqual(newLatestHeight, 19)
|
||||||
}
|
}
|
||||||
|
@ -480,7 +480,7 @@ final class FsBlockStorageTests: ZcashTestCase {
|
||||||
try await freshCache.write(blocks: fakeBlocks)
|
try await freshCache.write(blocks: fakeBlocks)
|
||||||
let endTime = Date()
|
let endTime = Date()
|
||||||
|
|
||||||
let latestHeight = await freshCache.latestHeight()
|
let latestHeight = try await freshCache.latestHeight()
|
||||||
|
|
||||||
XCTAssertEqual(latestHeight, 2000)
|
XCTAssertEqual(latestHeight, 2000)
|
||||||
|
|
||||||
|
|
|
@ -28,73 +28,6 @@ class NullBytesTests: XCTestCase {
|
||||||
XCTAssertFalse(DerivationTool(networkType: networkType).isValidTransparentAddress(tAddrWithNullBytes))
|
XCTAssertFalse(DerivationTool(networkType: networkType).isValidTransparentAddress(tAddrWithNullBytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
func testInitAccountTableNullBytes() async throws {
|
|
||||||
let wrongHash = "000000000\015c597fab53f\058b9e1ededbe8bd83ca0203788e2039eceeb0d65ca6"
|
|
||||||
let goodHash = "00000000015c597fab53f58b9e1ededbe8bd83ca0203788e2039eceeb0d65ca6"
|
|
||||||
let time: UInt32 = 1582235356
|
|
||||||
let height: Int32 = 735000
|
|
||||||
|
|
||||||
let wrongTree = """
|
|
||||||
0161f2ff97ff6ac6a90f9bce76c11710460f4944d8695aecc7dc99e34cad0131040011015325b185e23e82562db27817be996ffade9597181244f67efc40561aeb9dde1101dae\
|
|
||||||
ffadc9e38f755bcb55a847a1278518a0ba4a2ef33b2fe01bbb3eb242ab0070000000000011c51f9077e3f7e28e8e337eaf4bb99b41acbc853a37dcc1e172467a1c919fe410001\
|
|
||||||
0bb1f55481b2268ef31997dc0fb6b48a530bc17870220f156d832326c433eb0a010b3768d3bf7868a67823e022f49be67982d0588e7041c498a756024\0750065a4a0001a9e1b\
|
|
||||||
f4bccb48b14b544e770f21d48f2d3ad8d6ca54eccc92f60634e3078eb48013a1f7fb005388ac6f04099b647ed85d8b025d8ae4b178c2376b473b121b8c052000001d2ea556f49\
|
|
||||||
fb934dc76f087935a5c07788000b4e3aae24883adfec51b5f4d260
|
|
||||||
"""
|
|
||||||
|
|
||||||
let goodTree = """
|
|
||||||
0161f2ff97ff6ac6a90f9bce76c11710460f4944d8695aecc7dc99e34cad0131040011015325b185e23e82562db27817be996ffade9597181244f67efc40561aeb9dde1101dae\
|
|
||||||
ffadc9e38f755bcb55a847a1278518a0ba4a2ef33b2fe01bbb3eb242ab0070000000000011c51f9077e3f7e28e8e337eaf4bb99b41acbc853a37dcc1e172467a1c919fe410001\
|
|
||||||
0bb1f55481b2268ef31997dc0fb6b48a530bc17870220f156d832326c433eb0a010b3768d3bf7868a67823e022f49be67982d0588e7041c498a756024750065a4a0001a9e1bf4\
|
|
||||||
bccb48b14b544e770f21d48f2d3ad8d6ca54eccc92f60634e3078eb48013a1f7fb005388ac6f04099b647ed85d8b025d8ae4b178c2376b473b121b8c052000001d2ea556f49fb\
|
|
||||||
934dc76f087935a5c07788000b4e3aae24883adfec51b5f4d260
|
|
||||||
"""
|
|
||||||
|
|
||||||
let rustBackend = ZcashRustBackend.makeForTests(
|
|
||||||
dbData: try! __dataDbURL(),
|
|
||||||
fsBlockDbRoot: Environment.uniqueTestTempDirectory,
|
|
||||||
networkType: networkType
|
|
||||||
)
|
|
||||||
|
|
||||||
do {
|
|
||||||
_ = try await rustBackend.initBlocksTable(
|
|
||||||
height: height,
|
|
||||||
hash: wrongHash,
|
|
||||||
time: time,
|
|
||||||
saplingTree: goodTree
|
|
||||||
)
|
|
||||||
XCTFail("InitBlocksTable with Null bytes on hash string should have failed")
|
|
||||||
} catch {
|
|
||||||
guard let rustError = error as? ZcashError else {
|
|
||||||
XCTFail("Expected ZcashError")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if rustError.code != .rustInitBlocksTableHashContainsNullBytes {
|
|
||||||
XCTFail("expected error code \(ZcashError.rustInitBlocksTableHashContainsNullBytes.code.rawValue) and got error \(rustError)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
|
||||||
try await rustBackend.initBlocksTable(
|
|
||||||
height: height,
|
|
||||||
hash: goodHash,
|
|
||||||
time: time,
|
|
||||||
saplingTree: wrongTree
|
|
||||||
)
|
|
||||||
XCTFail("InitBlocksTable with Null bytes on saplingTree string should have failed")
|
|
||||||
} catch {
|
|
||||||
guard let rustError = error as? ZcashError else {
|
|
||||||
XCTFail("Expected ZcashError")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if rustError.code != .rustInitBlocksTableSaplingTreeContainsNullBytes {
|
|
||||||
XCTFail("expected error code \(ZcashError.rustInitBlocksTableSaplingTreeContainsNullBytes.code.rawValue) and got error \(rustError)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: [#716] fix, https://github.com/zcash/ZcashLightClientKit/issues/716
|
// TODO: [#716] fix, https://github.com/zcash/ZcashLightClientKit/issues/716
|
||||||
func testderiveExtendedFullViewingKeyWithNullBytes() throws {
|
func testderiveExtendedFullViewingKeyWithNullBytes() throws {
|
||||||
// let wrongSpendingKeys = SaplingExtendedSpendingKey(validatedEncoding: "secret-extended-key-main1qw28psv0qqqqpqr2ru0kss5equx6h0xjsuk5299xrsgdqnhe0cknkl8uqff34prwkyuegyhh5d4rdr8025nl7e0hm8r2txx3fuea5mq\0uy3wnsr9tlajsg4wwvw0xcfk8357k4h850rgj72kt4rx3fjdz99zs9f4neda35cq8tn3848yyvlg4w38gx75cyv9jdpve77x9eq6rtl6d9qyh8det4edevlnc70tg5kse670x50764gzhy60dta0yv3wsd4fsuaz686lgszc7nc9vv") // this spending key corresponds to the "demo app reference seed"
|
// let wrongSpendingKeys = SaplingExtendedSpendingKey(validatedEncoding: "secret-extended-key-main1qw28psv0qqqqpqr2ru0kss5equx6h0xjsuk5299xrsgdqnhe0cknkl8uqff34prwkyuegyhh5d4rdr8025nl7e0hm8r2txx3fuea5mq\0uy3wnsr9tlajsg4wwvw0xcfk8357k4h850rgj72kt4rx3fjdz99zs9f4neda35cq8tn3848yyvlg4w38gx75cyv9jdpve77x9eq6rtl6d9qyh8det4edevlnc70tg5kse670x50764gzhy60dta0yv3wsd4fsuaz686lgszc7nc9vv") // this spending key corresponds to the "demo app reference seed"
|
||||||
|
|
|
@ -304,13 +304,7 @@ class SynchronizerOfflineTests: ZcashTestCase {
|
||||||
let synchronizer = SDKSynchronizer(initializer: initializer)
|
let synchronizer = SDKSynchronizer(initializer: initializer)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
let derivationTool = DerivationTool(networkType: network.networkType)
|
_ = try await synchronizer.prepare(with: Environment.seedBytes, walletBirthday: 123000)
|
||||||
let spendingKey = try derivationTool.deriveUnifiedSpendingKey(
|
|
||||||
seed: Environment.seedBytes,
|
|
||||||
accountIndex: 0
|
|
||||||
)
|
|
||||||
let viewingKey = try derivationTool.deriveUnifiedFullViewingKey(from: spendingKey)
|
|
||||||
_ = try await synchronizer.prepare(with: Environment.seedBytes, viewingKeys: [viewingKey], walletBirthday: 123000)
|
|
||||||
XCTFail("Failure of prepare is expected.")
|
XCTFail("Failure of prepare is expected.")
|
||||||
} catch {
|
} catch {
|
||||||
if let error = error as? ZcashError, case let .initializerCantUpdateURLWithAlias(failedURL) = error {
|
if let error = error as? ZcashError, case let .initializerCantUpdateURLWithAlias(failedURL) = error {
|
||||||
|
|
|
@ -50,7 +50,7 @@ class WalletTests: ZcashTestCase {
|
||||||
|
|
||||||
let synchronizer = SDKSynchronizer(initializer: wallet)
|
let synchronizer = SDKSynchronizer(initializer: wallet)
|
||||||
do {
|
do {
|
||||||
guard case .success = try await synchronizer.prepare(with: seedData.bytes, viewingKeys: [viewingKey], walletBirthday: 663194) else {
|
guard case .success = try await synchronizer.prepare(with: seedData.bytes, walletBirthday: 663194) else {
|
||||||
XCTFail("Failed to initDataDb. Expected `.success` got: `.seedRequired`")
|
XCTFail("Failed to initDataDb. Expected `.success` got: `.seedRequired`")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,8 @@ class ZcashRustBackendTests: XCTestCase {
|
||||||
|
|
||||||
func testInitWithShortSeedAndFail() async throws {
|
func testInitWithShortSeedAndFail() async throws {
|
||||||
let seed = "testreferencealice"
|
let seed = "testreferencealice"
|
||||||
|
var treeState = TreeState()
|
||||||
|
treeState.height = 663193 // TODO: rest
|
||||||
|
|
||||||
let dbInit = try await rustBackend.initDataDb(seed: nil)
|
let dbInit = try await rustBackend.initDataDb(seed: nil)
|
||||||
|
|
||||||
|
@ -52,7 +54,7 @@ class ZcashRustBackendTests: XCTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
_ = try await rustBackend.createAccount(seed: Array(seed.utf8))
|
_ = try await rustBackend.createAccount(seed: Array(seed.utf8), treeState: treeState.serializedData(partial: false).bytes, recoverUntil: nil)
|
||||||
XCTFail("createAccount should fail here.")
|
XCTFail("createAccount should fail here.")
|
||||||
} catch { }
|
} catch { }
|
||||||
}
|
}
|
||||||
|
@ -100,7 +102,9 @@ class ZcashRustBackendTests: XCTestCase {
|
||||||
let initResult = try await rustBackend.initDataDb(seed: seed)
|
let initResult = try await rustBackend.initDataDb(seed: seed)
|
||||||
XCTAssertEqual(initResult, .success)
|
XCTAssertEqual(initResult, .success)
|
||||||
|
|
||||||
let usk = try await rustBackend.createAccount(seed: seed)
|
let treeState = Checkpoint.birthday(with: 1234567, network: ZcashMainnet()).treeState()
|
||||||
|
|
||||||
|
let usk = try await rustBackend.createAccount(seed: seed, treeState: treeState.serializedData(partial: false).bytes, recoverUntil: nil)
|
||||||
XCTAssertEqual(usk.account, 0)
|
XCTAssertEqual(usk.account, 0)
|
||||||
|
|
||||||
let expectedReceivers = try testVector.map {
|
let expectedReceivers = try testVector.map {
|
||||||
|
|
|
@ -48,17 +48,11 @@ class SynchronizerTests: ZcashTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testHundredBlocksSync() async throws {
|
func testHundredBlocksSync() async throws {
|
||||||
let derivationTool = DerivationTool(networkType: .mainnet)
|
|
||||||
guard let seedData = Data(base64Encoded: "9VDVOZZZOWWHpZtq1Ebridp3Qeux5C+HwiRR0g7Oi7HgnMs8Gfln83+/Q1NnvClcaSwM4ADFL1uZHxypEWlWXg==") else {
|
guard let seedData = Data(base64Encoded: "9VDVOZZZOWWHpZtq1Ebridp3Qeux5C+HwiRR0g7Oi7HgnMs8Gfln83+/Q1NnvClcaSwM4ADFL1uZHxypEWlWXg==") else {
|
||||||
XCTFail("seedData expected to be successfuly instantiated.")
|
XCTFail("seedData expected to be successfuly instantiated.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let seedBytes = [UInt8](seedData)
|
let seedBytes = [UInt8](seedData)
|
||||||
let spendingKey = try derivationTool.deriveUnifiedSpendingKey(
|
|
||||||
seed: seedBytes,
|
|
||||||
accountIndex: 0
|
|
||||||
)
|
|
||||||
let ufvk = try derivationTool.deriveUnifiedFullViewingKey(from: spendingKey)
|
|
||||||
let network = ZcashNetworkBuilder.network(for: .mainnet)
|
let network = ZcashNetworkBuilder.network(for: .mainnet)
|
||||||
let endpoint = LightWalletEndpoint(address: "lightwalletd.electriccoin.co", port: 9067, secure: true)
|
let endpoint = LightWalletEndpoint(address: "lightwalletd.electriccoin.co", port: 9067, secure: true)
|
||||||
|
|
||||||
|
@ -87,7 +81,7 @@ class SynchronizerTests: ZcashTestCase {
|
||||||
guard let synchronizer else { fatalError("Synchronizer not initialized.") }
|
guard let synchronizer else { fatalError("Synchronizer not initialized.") }
|
||||||
|
|
||||||
synchronizer.metrics.enableMetrics()
|
synchronizer.metrics.enableMetrics()
|
||||||
_ = try await synchronizer.prepare(with: seedBytes, viewingKeys: [ufvk], walletBirthday: birthday)
|
_ = try await synchronizer.prepare(with: seedBytes, walletBirthday: birthday)
|
||||||
|
|
||||||
let syncSyncedExpectation = XCTestExpectation(description: "synchronizerSynced Expectation")
|
let syncSyncedExpectation = XCTestExpectation(description: "synchronizerSynced Expectation")
|
||||||
sdkSynchronizerInternalSyncStatusHandler.subscribe(to: synchronizer.stateStream, expectations: [.synced: syncSyncedExpectation])
|
sdkSynchronizerInternalSyncStatusHandler.subscribe(to: synchronizer.stateStream, expectations: [.synced: syncSyncedExpectation])
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Generated using Sourcery 2.0.2 — https://github.com/krzysztofzablocki/Sourcery
|
// Generated using Sourcery 2.0.3 — https://github.com/krzysztofzablocki/Sourcery
|
||||||
// DO NOT EDIT
|
// DO NOT EDIT
|
||||||
import Combine
|
import Combine
|
||||||
@testable import ZcashLightClientKit
|
@testable import ZcashLightClientKit
|
||||||
|
@ -405,17 +405,21 @@ class CompactBlockRepositoryMock: CompactBlockRepository {
|
||||||
|
|
||||||
// MARK: - latestHeight
|
// MARK: - latestHeight
|
||||||
|
|
||||||
|
var latestHeightThrowableError: Error?
|
||||||
var latestHeightCallsCount = 0
|
var latestHeightCallsCount = 0
|
||||||
var latestHeightCalled: Bool {
|
var latestHeightCalled: Bool {
|
||||||
return latestHeightCallsCount > 0
|
return latestHeightCallsCount > 0
|
||||||
}
|
}
|
||||||
var latestHeightReturnValue: BlockHeight!
|
var latestHeightReturnValue: BlockHeight!
|
||||||
var latestHeightClosure: (() async -> BlockHeight)?
|
var latestHeightClosure: (() async throws -> BlockHeight)?
|
||||||
|
|
||||||
func latestHeight() async -> BlockHeight {
|
func latestHeight() async throws -> BlockHeight {
|
||||||
|
if let error = latestHeightThrowableError {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
latestHeightCallsCount += 1
|
latestHeightCallsCount += 1
|
||||||
if let closure = latestHeightClosure {
|
if let closure = latestHeightClosure {
|
||||||
return await closure()
|
return try await closure()
|
||||||
} else {
|
} else {
|
||||||
return latestHeightReturnValue
|
return latestHeightReturnValue
|
||||||
}
|
}
|
||||||
|
@ -1042,25 +1046,25 @@ class SynchronizerMock: Synchronizer {
|
||||||
|
|
||||||
// MARK: - prepare
|
// MARK: - prepare
|
||||||
|
|
||||||
var prepareWithViewingKeysWalletBirthdayThrowableError: Error?
|
var prepareWithWalletBirthdayThrowableError: Error?
|
||||||
var prepareWithViewingKeysWalletBirthdayCallsCount = 0
|
var prepareWithWalletBirthdayCallsCount = 0
|
||||||
var prepareWithViewingKeysWalletBirthdayCalled: Bool {
|
var prepareWithWalletBirthdayCalled: Bool {
|
||||||
return prepareWithViewingKeysWalletBirthdayCallsCount > 0
|
return prepareWithWalletBirthdayCallsCount > 0
|
||||||
}
|
}
|
||||||
var prepareWithViewingKeysWalletBirthdayReceivedArguments: (seed: [UInt8]?, viewingKeys: [UnifiedFullViewingKey], walletBirthday: BlockHeight)?
|
var prepareWithWalletBirthdayReceivedArguments: (seed: [UInt8]?, walletBirthday: BlockHeight)?
|
||||||
var prepareWithViewingKeysWalletBirthdayReturnValue: Initializer.InitializationResult!
|
var prepareWithWalletBirthdayReturnValue: Initializer.InitializationResult!
|
||||||
var prepareWithViewingKeysWalletBirthdayClosure: (([UInt8]?, [UnifiedFullViewingKey], BlockHeight) async throws -> Initializer.InitializationResult)?
|
var prepareWithWalletBirthdayClosure: (([UInt8]?, BlockHeight) async throws -> Initializer.InitializationResult)?
|
||||||
|
|
||||||
func prepare(with seed: [UInt8]?, viewingKeys: [UnifiedFullViewingKey], walletBirthday: BlockHeight) async throws -> Initializer.InitializationResult {
|
func prepare(with seed: [UInt8]?, walletBirthday: BlockHeight) async throws -> Initializer.InitializationResult {
|
||||||
if let error = prepareWithViewingKeysWalletBirthdayThrowableError {
|
if let error = prepareWithWalletBirthdayThrowableError {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
prepareWithViewingKeysWalletBirthdayCallsCount += 1
|
prepareWithWalletBirthdayCallsCount += 1
|
||||||
prepareWithViewingKeysWalletBirthdayReceivedArguments = (seed: seed, viewingKeys: viewingKeys, walletBirthday: walletBirthday)
|
prepareWithWalletBirthdayReceivedArguments = (seed: seed, walletBirthday: walletBirthday)
|
||||||
if let closure = prepareWithViewingKeysWalletBirthdayClosure {
|
if let closure = prepareWithWalletBirthdayClosure {
|
||||||
return try await closure(seed, viewingKeys, walletBirthday)
|
return try await closure(seed, walletBirthday)
|
||||||
} else {
|
} else {
|
||||||
return prepareWithViewingKeysWalletBirthdayReturnValue
|
return prepareWithWalletBirthdayReturnValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2055,34 +2059,34 @@ actor ZcashRustBackendWeldingMock: ZcashRustBackendWelding {
|
||||||
|
|
||||||
// MARK: - createAccount
|
// MARK: - createAccount
|
||||||
|
|
||||||
var createAccountSeedThrowableError: Error?
|
var createAccountSeedTreeStateRecoverUntilThrowableError: Error?
|
||||||
func setCreateAccountSeedThrowableError(_ param: Error?) async {
|
func setCreateAccountSeedTreeStateRecoverUntilThrowableError(_ param: Error?) async {
|
||||||
createAccountSeedThrowableError = param
|
createAccountSeedTreeStateRecoverUntilThrowableError = param
|
||||||
}
|
}
|
||||||
var createAccountSeedCallsCount = 0
|
var createAccountSeedTreeStateRecoverUntilCallsCount = 0
|
||||||
var createAccountSeedCalled: Bool {
|
var createAccountSeedTreeStateRecoverUntilCalled: Bool {
|
||||||
return createAccountSeedCallsCount > 0
|
return createAccountSeedTreeStateRecoverUntilCallsCount > 0
|
||||||
}
|
}
|
||||||
var createAccountSeedReceivedSeed: [UInt8]?
|
var createAccountSeedTreeStateRecoverUntilReceivedArguments: (seed: [UInt8], treeState: [UInt8], recoverUntil: UInt32?)?
|
||||||
var createAccountSeedReturnValue: UnifiedSpendingKey!
|
var createAccountSeedTreeStateRecoverUntilReturnValue: UnifiedSpendingKey!
|
||||||
func setCreateAccountSeedReturnValue(_ param: UnifiedSpendingKey) async {
|
func setCreateAccountSeedTreeStateRecoverUntilReturnValue(_ param: UnifiedSpendingKey) async {
|
||||||
createAccountSeedReturnValue = param
|
createAccountSeedTreeStateRecoverUntilReturnValue = param
|
||||||
}
|
}
|
||||||
var createAccountSeedClosure: (([UInt8]) async throws -> UnifiedSpendingKey)?
|
var createAccountSeedTreeStateRecoverUntilClosure: (([UInt8], [UInt8], UInt32?) async throws -> UnifiedSpendingKey)?
|
||||||
func setCreateAccountSeedClosure(_ param: (([UInt8]) async throws -> UnifiedSpendingKey)?) async {
|
func setCreateAccountSeedTreeStateRecoverUntilClosure(_ param: (([UInt8], [UInt8], UInt32?) async throws -> UnifiedSpendingKey)?) async {
|
||||||
createAccountSeedClosure = param
|
createAccountSeedTreeStateRecoverUntilClosure = param
|
||||||
}
|
}
|
||||||
|
|
||||||
func createAccount(seed: [UInt8]) async throws -> UnifiedSpendingKey {
|
func createAccount(seed: [UInt8], treeState: [UInt8], recoverUntil: UInt32?) async throws -> UnifiedSpendingKey {
|
||||||
if let error = createAccountSeedThrowableError {
|
if let error = createAccountSeedTreeStateRecoverUntilThrowableError {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
createAccountSeedCallsCount += 1
|
createAccountSeedTreeStateRecoverUntilCallsCount += 1
|
||||||
createAccountSeedReceivedSeed = seed
|
createAccountSeedTreeStateRecoverUntilReceivedArguments = (seed: seed, treeState: treeState, recoverUntil: recoverUntil)
|
||||||
if let closure = createAccountSeedClosure {
|
if let closure = createAccountSeedTreeStateRecoverUntilClosure {
|
||||||
return try await closure(seed)
|
return try await closure(seed, treeState, recoverUntil)
|
||||||
} else {
|
} else {
|
||||||
return createAccountSeedReturnValue
|
return createAccountSeedTreeStateRecoverUntilReturnValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2342,31 +2346,6 @@ actor ZcashRustBackendWeldingMock: ZcashRustBackendWelding {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - initAccountsTable
|
|
||||||
|
|
||||||
var initAccountsTableUfvksThrowableError: Error?
|
|
||||||
func setInitAccountsTableUfvksThrowableError(_ param: Error?) async {
|
|
||||||
initAccountsTableUfvksThrowableError = param
|
|
||||||
}
|
|
||||||
var initAccountsTableUfvksCallsCount = 0
|
|
||||||
var initAccountsTableUfvksCalled: Bool {
|
|
||||||
return initAccountsTableUfvksCallsCount > 0
|
|
||||||
}
|
|
||||||
var initAccountsTableUfvksReceivedUfvks: [UnifiedFullViewingKey]?
|
|
||||||
var initAccountsTableUfvksClosure: (([UnifiedFullViewingKey]) async throws -> Void)?
|
|
||||||
func setInitAccountsTableUfvksClosure(_ param: (([UnifiedFullViewingKey]) async throws -> Void)?) async {
|
|
||||||
initAccountsTableUfvksClosure = param
|
|
||||||
}
|
|
||||||
|
|
||||||
func initAccountsTable(ufvks: [UnifiedFullViewingKey]) async throws {
|
|
||||||
if let error = initAccountsTableUfvksThrowableError {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
initAccountsTableUfvksCallsCount += 1
|
|
||||||
initAccountsTableUfvksReceivedUfvks = ufvks
|
|
||||||
try await initAccountsTableUfvksClosure!(ufvks)
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - initDataDb
|
// MARK: - initDataDb
|
||||||
|
|
||||||
var initDataDbSeedThrowableError: Error?
|
var initDataDbSeedThrowableError: Error?
|
||||||
|
@ -2400,31 +2379,6 @@ actor ZcashRustBackendWeldingMock: ZcashRustBackendWelding {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - initBlocksTable
|
|
||||||
|
|
||||||
var initBlocksTableHeightHashTimeSaplingTreeThrowableError: Error?
|
|
||||||
func setInitBlocksTableHeightHashTimeSaplingTreeThrowableError(_ param: Error?) async {
|
|
||||||
initBlocksTableHeightHashTimeSaplingTreeThrowableError = param
|
|
||||||
}
|
|
||||||
var initBlocksTableHeightHashTimeSaplingTreeCallsCount = 0
|
|
||||||
var initBlocksTableHeightHashTimeSaplingTreeCalled: Bool {
|
|
||||||
return initBlocksTableHeightHashTimeSaplingTreeCallsCount > 0
|
|
||||||
}
|
|
||||||
var initBlocksTableHeightHashTimeSaplingTreeReceivedArguments: (height: Int32, hash: String, time: UInt32, saplingTree: String)?
|
|
||||||
var initBlocksTableHeightHashTimeSaplingTreeClosure: ((Int32, String, UInt32, String) async throws -> Void)?
|
|
||||||
func setInitBlocksTableHeightHashTimeSaplingTreeClosure(_ param: ((Int32, String, UInt32, String) async throws -> Void)?) async {
|
|
||||||
initBlocksTableHeightHashTimeSaplingTreeClosure = param
|
|
||||||
}
|
|
||||||
|
|
||||||
func initBlocksTable(height: Int32, hash: String, time: UInt32, saplingTree: String) async throws {
|
|
||||||
if let error = initBlocksTableHeightHashTimeSaplingTreeThrowableError {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
initBlocksTableHeightHashTimeSaplingTreeCallsCount += 1
|
|
||||||
initBlocksTableHeightHashTimeSaplingTreeReceivedArguments = (height: height, hash: hash, time: time, saplingTree: saplingTree)
|
|
||||||
try await initBlocksTableHeightHashTimeSaplingTreeClosure!(height, hash, time, saplingTree)
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - listTransparentReceivers
|
// MARK: - listTransparentReceivers
|
||||||
|
|
||||||
var listTransparentReceiversAccountThrowableError: Error?
|
var listTransparentReceiversAccountThrowableError: Error?
|
||||||
|
@ -2574,6 +2528,124 @@ actor ZcashRustBackendWeldingMock: ZcashRustBackendWelding {
|
||||||
try await rewindCacheToHeightHeightClosure!(height)
|
try await rewindCacheToHeightHeightClosure!(height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - updateChainTip
|
||||||
|
|
||||||
|
var updateChainTipHeightThrowableError: Error?
|
||||||
|
func setUpdateChainTipHeightThrowableError(_ param: Error?) async {
|
||||||
|
updateChainTipHeightThrowableError = param
|
||||||
|
}
|
||||||
|
var updateChainTipHeightCallsCount = 0
|
||||||
|
var updateChainTipHeightCalled: Bool {
|
||||||
|
return updateChainTipHeightCallsCount > 0
|
||||||
|
}
|
||||||
|
var updateChainTipHeightReceivedHeight: Int32?
|
||||||
|
var updateChainTipHeightClosure: ((Int32) async throws -> Void)?
|
||||||
|
func setUpdateChainTipHeightClosure(_ param: ((Int32) async throws -> Void)?) async {
|
||||||
|
updateChainTipHeightClosure = param
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateChainTip(height: Int32) async throws {
|
||||||
|
if let error = updateChainTipHeightThrowableError {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
updateChainTipHeightCallsCount += 1
|
||||||
|
updateChainTipHeightReceivedHeight = height
|
||||||
|
try await updateChainTipHeightClosure!(height)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - fullyScannedHeight
|
||||||
|
|
||||||
|
var fullyScannedHeightThrowableError: Error?
|
||||||
|
func setFullyScannedHeightThrowableError(_ param: Error?) async {
|
||||||
|
fullyScannedHeightThrowableError = param
|
||||||
|
}
|
||||||
|
var fullyScannedHeightCallsCount = 0
|
||||||
|
var fullyScannedHeightCalled: Bool {
|
||||||
|
return fullyScannedHeightCallsCount > 0
|
||||||
|
}
|
||||||
|
var fullyScannedHeightReturnValue: BlockHeight?
|
||||||
|
func setFullyScannedHeightReturnValue(_ param: BlockHeight?) async {
|
||||||
|
fullyScannedHeightReturnValue = param
|
||||||
|
}
|
||||||
|
var fullyScannedHeightClosure: (() async throws -> BlockHeight?)?
|
||||||
|
func setFullyScannedHeightClosure(_ param: (() async throws -> BlockHeight?)?) async {
|
||||||
|
fullyScannedHeightClosure = param
|
||||||
|
}
|
||||||
|
|
||||||
|
func fullyScannedHeight() async throws -> BlockHeight? {
|
||||||
|
if let error = fullyScannedHeightThrowableError {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
fullyScannedHeightCallsCount += 1
|
||||||
|
if let closure = fullyScannedHeightClosure {
|
||||||
|
return try await closure()
|
||||||
|
} else {
|
||||||
|
return fullyScannedHeightReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - maxScannedHeight
|
||||||
|
|
||||||
|
var maxScannedHeightThrowableError: Error?
|
||||||
|
func setMaxScannedHeightThrowableError(_ param: Error?) async {
|
||||||
|
maxScannedHeightThrowableError = param
|
||||||
|
}
|
||||||
|
var maxScannedHeightCallsCount = 0
|
||||||
|
var maxScannedHeightCalled: Bool {
|
||||||
|
return maxScannedHeightCallsCount > 0
|
||||||
|
}
|
||||||
|
var maxScannedHeightReturnValue: BlockHeight?
|
||||||
|
func setMaxScannedHeightReturnValue(_ param: BlockHeight?) async {
|
||||||
|
maxScannedHeightReturnValue = param
|
||||||
|
}
|
||||||
|
var maxScannedHeightClosure: (() async throws -> BlockHeight?)?
|
||||||
|
func setMaxScannedHeightClosure(_ param: (() async throws -> BlockHeight?)?) async {
|
||||||
|
maxScannedHeightClosure = param
|
||||||
|
}
|
||||||
|
|
||||||
|
func maxScannedHeight() async throws -> BlockHeight? {
|
||||||
|
if let error = maxScannedHeightThrowableError {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
maxScannedHeightCallsCount += 1
|
||||||
|
if let closure = maxScannedHeightClosure {
|
||||||
|
return try await closure()
|
||||||
|
} else {
|
||||||
|
return maxScannedHeightReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - getScanProgress
|
||||||
|
|
||||||
|
var getScanProgressThrowableError: Error?
|
||||||
|
func setGetScanProgressThrowableError(_ param: Error?) async {
|
||||||
|
getScanProgressThrowableError = param
|
||||||
|
}
|
||||||
|
var getScanProgressCallsCount = 0
|
||||||
|
var getScanProgressCalled: Bool {
|
||||||
|
return getScanProgressCallsCount > 0
|
||||||
|
}
|
||||||
|
var getScanProgressReturnValue: ScanProgress?
|
||||||
|
func setGetScanProgressReturnValue(_ param: ScanProgress?) async {
|
||||||
|
getScanProgressReturnValue = param
|
||||||
|
}
|
||||||
|
var getScanProgressClosure: (() async throws -> ScanProgress?)?
|
||||||
|
func setGetScanProgressClosure(_ param: (() async throws -> ScanProgress?)?) async {
|
||||||
|
getScanProgressClosure = param
|
||||||
|
}
|
||||||
|
|
||||||
|
func getScanProgress() async throws -> ScanProgress? {
|
||||||
|
if let error = getScanProgressThrowableError {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
getScanProgressCallsCount += 1
|
||||||
|
if let closure = getScanProgressClosure {
|
||||||
|
return try await closure()
|
||||||
|
} else {
|
||||||
|
return getScanProgressReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - suggestScanRanges
|
// MARK: - suggestScanRanges
|
||||||
|
|
||||||
var suggestScanRangesThrowableError: Error?
|
var suggestScanRangesThrowableError: Error?
|
||||||
|
@ -2745,6 +2817,10 @@ actor ZcashRustBackendWeldingMock: ZcashRustBackendWelding {
|
||||||
|
|
||||||
// MARK: - latestCachedBlockHeight
|
// MARK: - latestCachedBlockHeight
|
||||||
|
|
||||||
|
var latestCachedBlockHeightThrowableError: Error?
|
||||||
|
func setLatestCachedBlockHeightThrowableError(_ param: Error?) async {
|
||||||
|
latestCachedBlockHeightThrowableError = param
|
||||||
|
}
|
||||||
var latestCachedBlockHeightCallsCount = 0
|
var latestCachedBlockHeightCallsCount = 0
|
||||||
var latestCachedBlockHeightCalled: Bool {
|
var latestCachedBlockHeightCalled: Bool {
|
||||||
return latestCachedBlockHeightCallsCount > 0
|
return latestCachedBlockHeightCallsCount > 0
|
||||||
|
@ -2753,15 +2829,18 @@ actor ZcashRustBackendWeldingMock: ZcashRustBackendWelding {
|
||||||
func setLatestCachedBlockHeightReturnValue(_ param: BlockHeight) async {
|
func setLatestCachedBlockHeightReturnValue(_ param: BlockHeight) async {
|
||||||
latestCachedBlockHeightReturnValue = param
|
latestCachedBlockHeightReturnValue = param
|
||||||
}
|
}
|
||||||
var latestCachedBlockHeightClosure: (() async -> BlockHeight)?
|
var latestCachedBlockHeightClosure: (() async throws -> BlockHeight)?
|
||||||
func setLatestCachedBlockHeightClosure(_ param: (() async -> BlockHeight)?) async {
|
func setLatestCachedBlockHeightClosure(_ param: (() async throws -> BlockHeight)?) async {
|
||||||
latestCachedBlockHeightClosure = param
|
latestCachedBlockHeightClosure = param
|
||||||
}
|
}
|
||||||
|
|
||||||
func latestCachedBlockHeight() async -> BlockHeight {
|
func latestCachedBlockHeight() async throws -> BlockHeight {
|
||||||
|
if let error = latestCachedBlockHeightThrowableError {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
latestCachedBlockHeightCallsCount += 1
|
latestCachedBlockHeightCallsCount += 1
|
||||||
if let closure = latestCachedBlockHeightClosure {
|
if let closure = latestCachedBlockHeightClosure {
|
||||||
return await closure()
|
return try await closure()
|
||||||
} else {
|
} else {
|
||||||
return latestCachedBlockHeightReturnValue
|
return latestCachedBlockHeightReturnValue
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
scriptDir=${0:a:h}
|
scriptDir=${0:a:h}
|
||||||
cd "${scriptDir}"
|
cd "${scriptDir}"
|
||||||
|
|
||||||
sourcery_version=2.0.2
|
sourcery_version=2.0.3
|
||||||
|
|
||||||
if which sourcery >/dev/null; then
|
if which sourcery >/dev/null; then
|
||||||
if [[ $(sourcery --version) != $sourcery_version ]]; then
|
if [[ $(sourcery --version) != $sourcery_version ]]; then
|
||||||
|
|
|
@ -90,17 +90,15 @@ class RustBackendMockHelper {
|
||||||
await rustBackendMock.setLatestCachedBlockHeightReturnValue(.empty())
|
await rustBackendMock.setLatestCachedBlockHeightReturnValue(.empty())
|
||||||
await rustBackendMock.setInitBlockMetadataDbClosure() { }
|
await rustBackendMock.setInitBlockMetadataDbClosure() { }
|
||||||
await rustBackendMock.setWriteBlocksMetadataBlocksClosure() { _ in }
|
await rustBackendMock.setWriteBlocksMetadataBlocksClosure() { _ in }
|
||||||
await rustBackendMock.setInitAccountsTableUfvksClosure() { _ in }
|
|
||||||
await rustBackendMock.setGetTransparentBalanceAccountReturnValue(0)
|
await rustBackendMock.setGetTransparentBalanceAccountReturnValue(0)
|
||||||
await rustBackendMock.setGetVerifiedBalanceAccountReturnValue(0)
|
await rustBackendMock.setGetVerifiedBalanceAccountReturnValue(0)
|
||||||
await rustBackendMock.setListTransparentReceiversAccountReturnValue([])
|
await rustBackendMock.setListTransparentReceiversAccountReturnValue([])
|
||||||
await rustBackendMock.setGetCurrentAddressAccountThrowableError(ZcashError.rustGetCurrentAddress("mocked error"))
|
await rustBackendMock.setGetCurrentAddressAccountThrowableError(ZcashError.rustGetCurrentAddress("mocked error"))
|
||||||
await rustBackendMock.setGetNextAvailableAddressAccountThrowableError(ZcashError.rustGetNextAvailableAddress("mocked error"))
|
await rustBackendMock.setGetNextAvailableAddressAccountThrowableError(ZcashError.rustGetNextAvailableAddress("mocked error"))
|
||||||
await rustBackendMock.setCreateAccountSeedThrowableError(ZcashError.rustInitAccountsTableViewingKeyCotainsNullBytes)
|
await rustBackendMock.setCreateAccountSeedTreeStateRecoverUntilThrowableError(ZcashError.rustInitAccountsTableViewingKeyCotainsNullBytes)
|
||||||
await rustBackendMock.setGetMemoTxIdOutputIndexReturnValue(nil)
|
await rustBackendMock.setGetMemoTxIdOutputIndexReturnValue(nil)
|
||||||
await rustBackendMock.setInitDataDbSeedReturnValue(.seedRequired)
|
await rustBackendMock.setInitDataDbSeedReturnValue(.seedRequired)
|
||||||
await rustBackendMock.setGetNearestRewindHeightHeightReturnValue(-1)
|
await rustBackendMock.setGetNearestRewindHeightHeightReturnValue(-1)
|
||||||
await rustBackendMock.setInitBlocksTableHeightHashTimeSaplingTreeClosure() { _, _, _, _ in }
|
|
||||||
await rustBackendMock.setPutUnspentTransparentOutputTxidIndexScriptValueHeightClosure() { _, _, _, _, _ in }
|
await rustBackendMock.setPutUnspentTransparentOutputTxidIndexScriptValueHeightClosure() { _, _, _, _, _ in }
|
||||||
await rustBackendMock.setCreateToAddressUskToValueMemoThrowableError(ZcashError.rustCreateToAddress("mocked error"))
|
await rustBackendMock.setCreateToAddressUskToValueMemoThrowableError(ZcashError.rustCreateToAddress("mocked error"))
|
||||||
await rustBackendMock.setShieldFundsUskMemoShieldingThresholdThrowableError(ZcashError.rustShieldFunds("mocked error"))
|
await rustBackendMock.setShieldFundsUskMemoShieldingThresholdThrowableError(ZcashError.rustShieldFunds("mocked error"))
|
||||||
|
@ -110,15 +108,6 @@ class RustBackendMockHelper {
|
||||||
return try await rustBackend.initDataDb(seed: seed)
|
return try await rustBackend.initDataDb(seed: seed)
|
||||||
}
|
}
|
||||||
|
|
||||||
await rustBackendMock.setInitBlocksTableHeightHashTimeSaplingTreeClosure() { height, hash, time, saplingTree in
|
|
||||||
try await rustBackend.initBlocksTable(
|
|
||||||
height: height,
|
|
||||||
hash: hash,
|
|
||||||
time: time,
|
|
||||||
saplingTree: saplingTree
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
await rustBackendMock.setGetBalanceAccountClosure() { account in
|
await rustBackendMock.setGetBalanceAccountClosure() { account in
|
||||||
return try await rustBackend.getBalance(account: account)
|
return try await rustBackend.getBalance(account: account)
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ class TestCoordinator {
|
||||||
}
|
}
|
||||||
|
|
||||||
func prepare(seed: [UInt8]) async throws -> Initializer.InitializationResult {
|
func prepare(seed: [UInt8]) async throws -> Initializer.InitializationResult {
|
||||||
return try await synchronizer.prepare(with: seed, viewingKeys: [viewingKey], walletBirthday: self.birthday)
|
return try await synchronizer.prepare(with: seed, walletBirthday: self.birthday)
|
||||||
}
|
}
|
||||||
|
|
||||||
func stop() async throws {
|
func stop() async throws {
|
||||||
|
|
Loading…
Reference in New Issue