Fix compiler errors
This commit is contained in:
parent
dbd4b8934c
commit
01d85f5748
|
@ -500,7 +500,6 @@ public actor CompactBlockProcessor {
|
||||||
notifyError(CompactBlockProcessorError.maxAttemptsReached(attempts: self.maxAttempts))
|
notifyError(CompactBlockProcessorError.maxAttemptsReached(attempts: self.maxAttempts))
|
||||||
case .downloading, .validating, .scanning, .enhancing, .fetching:
|
case .downloading, .validating, .scanning, .enhancing, .fetching:
|
||||||
LoggerProxy.debug("Warning: compact block processor was started while busy!!!!")
|
LoggerProxy.debug("Warning: compact block processor was started while busy!!!!")
|
||||||
needsToStartScanningWhenStopped.set(true)
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1000,9 +999,6 @@ extension CompactBlockProcessor {
|
||||||
guard accountIndex >= 0 else {
|
guard accountIndex >= 0 else {
|
||||||
throw CompactBlockProcessorError.invalidAccount
|
throw CompactBlockProcessorError.invalidAccount
|
||||||
}
|
}
|
||||||
return try utxoCacheBalance(tAddress: tAddress)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return WalletBalance(
|
return WalletBalance(
|
||||||
verified: Zatoshi(
|
verified: Zatoshi(
|
||||||
|
|
|
@ -93,7 +93,7 @@ public protocol Synchronizer {
|
||||||
/// Gets the sapling shielded address for the given account.
|
/// Gets the sapling shielded address for the given account.
|
||||||
/// - Parameter accountIndex: the optional accountId whose address is of interest. By default, the first account is used.
|
/// - Parameter accountIndex: the optional accountId whose address is of interest. By default, the first account is used.
|
||||||
/// - Returns the address or nil if account index is incorrect
|
/// - Returns the address or nil if account index is incorrect
|
||||||
func getSaplingAddress(accountIndex: Int) -> SaplingAddress?
|
func getSaplingAddress(accountIndex: Int) async -> SaplingAddress?
|
||||||
|
|
||||||
/// Gets the unified address for the given account.
|
/// Gets the unified address for the given account.
|
||||||
/// - Parameter accountIndex: the optional accountId whose address is of interest. By default, the first account is used.
|
/// - Parameter accountIndex: the optional accountId whose address is of interest. By default, the first account is used.
|
||||||
|
|
|
@ -627,10 +627,10 @@ public class SDKSynchronizer: Synchronizer {
|
||||||
|
|
||||||
/// Returns the last stored transparent balance
|
/// Returns the last stored transparent balance
|
||||||
public func getTransparentBalance(accountIndex: Int) async throws -> WalletBalance {
|
public func getTransparentBalance(accountIndex: Int) async throws -> WalletBalance {
|
||||||
try blockProcessor.getTransparentBalance(accountIndex: accountIndex)
|
try await blockProcessor.getTransparentBalance(accountIndex: accountIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func rewind(_ policy: RewindPolicy) throws {
|
public func rewind(_ policy: RewindPolicy) async throws {
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
var height: BlockHeight?
|
var height: BlockHeight?
|
||||||
|
|
|
@ -34,12 +34,14 @@ class AdvancedReOrgTests: XCTestCase {
|
||||||
|
|
||||||
override func setUpWithError() throws {
|
override func setUpWithError() throws {
|
||||||
try super.setUpWithError()
|
try super.setUpWithError()
|
||||||
coordinator = try TestCoordinator(
|
Task{ @MainActor [self] in
|
||||||
|
self.coordinator = try await TestCoordinator(
|
||||||
seed: seedPhrase,
|
seed: seedPhrase,
|
||||||
walletBirthday: birthday + 50, //don't use an exact birthday, users never do.
|
walletBirthday: birthday + 50, //don't use an exact birthday, users never do.
|
||||||
channelProvider: ChannelProvider(),
|
channelProvider: ChannelProvider(),
|
||||||
network: network
|
network: network
|
||||||
)
|
)
|
||||||
|
}
|
||||||
try coordinator.reset(saplingActivation: 663150, branchID: self.branchID, chainName: self.chainName)
|
try coordinator.reset(saplingActivation: 663150, branchID: self.branchID, chainName: self.chainName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,12 +30,14 @@ class BalanceTests: XCTestCase {
|
||||||
|
|
||||||
override func setUpWithError() throws {
|
override func setUpWithError() throws {
|
||||||
try super.setUpWithError()
|
try super.setUpWithError()
|
||||||
coordinator = try TestCoordinator(
|
Task{ @MainActor [self] in
|
||||||
|
self.coordinator = try await TestCoordinator(
|
||||||
seed: seedPhrase,
|
seed: seedPhrase,
|
||||||
walletBirthday: birthday,
|
walletBirthday: birthday,
|
||||||
channelProvider: ChannelProvider(),
|
channelProvider: ChannelProvider(),
|
||||||
network: network
|
network: network
|
||||||
)
|
)
|
||||||
|
}
|
||||||
try coordinator.reset(saplingActivation: 663150, branchID: "e9ff75a6", chainName: "main")
|
try coordinator.reset(saplingActivation: 663150, branchID: "e9ff75a6", chainName: "main")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,12 +33,14 @@ class DarksideSanityCheckTests: XCTestCase {
|
||||||
|
|
||||||
override func setUpWithError() throws {
|
override func setUpWithError() throws {
|
||||||
try super.setUpWithError()
|
try super.setUpWithError()
|
||||||
coordinator = try TestCoordinator(
|
Task { @MainActor [self] in
|
||||||
|
self.coordinator = try await TestCoordinator(
|
||||||
seed: seedPhrase,
|
seed: seedPhrase,
|
||||||
walletBirthday: birthday,
|
walletBirthday: birthday,
|
||||||
channelProvider: ChannelProvider(),
|
channelProvider: ChannelProvider(),
|
||||||
network: network
|
network: network
|
||||||
)
|
)
|
||||||
|
}
|
||||||
try coordinator.reset(saplingActivation: birthday, branchID: branchID, chainName: chainName)
|
try coordinator.reset(saplingActivation: birthday, branchID: branchID, chainName: chainName)
|
||||||
try coordinator.resetBlocks(dataset: .default)
|
try coordinator.resetBlocks(dataset: .default)
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,12 +31,15 @@ class PendingTransactionUpdatesTest: XCTestCase {
|
||||||
let network = DarksideWalletDNetwork()
|
let network = DarksideWalletDNetwork()
|
||||||
override func setUpWithError() throws {
|
override func setUpWithError() throws {
|
||||||
try super.setUpWithError()
|
try super.setUpWithError()
|
||||||
coordinator = try TestCoordinator(
|
Task{ @MainActor in
|
||||||
|
coordinator = try await TestCoordinator(
|
||||||
seed: seedPhrase,
|
seed: seedPhrase,
|
||||||
walletBirthday: birthday,
|
walletBirthday: birthday,
|
||||||
channelProvider: ChannelProvider(),
|
channelProvider: ChannelProvider(),
|
||||||
network: network
|
network: network
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
try coordinator.reset(saplingActivation: 663150, branchID: "e9ff75a6", chainName: "main")
|
try coordinator.reset(saplingActivation: 663150, branchID: "e9ff75a6", chainName: "main")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,18 +47,23 @@ class ReOrgTests: XCTestCase {
|
||||||
|
|
||||||
override func setUpWithError() throws {
|
override func setUpWithError() throws {
|
||||||
try super.setUpWithError()
|
try super.setUpWithError()
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(
|
NotificationCenter.default.addObserver(
|
||||||
self,
|
self,
|
||||||
selector: #selector(handleReOrgNotification(_:)),
|
selector: #selector(handleReOrgNotification(_:)),
|
||||||
name: Notification.Name.blockProcessorHandledReOrg,
|
name: Notification.Name.blockProcessorHandledReOrg,
|
||||||
object: nil
|
object: nil
|
||||||
)
|
)
|
||||||
coordinator = try TestCoordinator(
|
|
||||||
|
Task{ @MainActor [self] in
|
||||||
|
coordinator = try await TestCoordinator(
|
||||||
seed: seedPhrase,
|
seed: seedPhrase,
|
||||||
walletBirthday: birthday,
|
walletBirthday: birthday,
|
||||||
channelProvider: ChannelProvider(),
|
channelProvider: ChannelProvider(),
|
||||||
network: network
|
network: network
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
try coordinator.reset(saplingActivation: birthday, branchID: branchID, chainName: chainName)
|
try coordinator.reset(saplingActivation: birthday, branchID: branchID, chainName: chainName)
|
||||||
try coordinator.resetBlocks(dataset: .default)
|
try coordinator.resetBlocks(dataset: .default)
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,14 +34,14 @@ class RewindRescanTests: XCTestCase {
|
||||||
|
|
||||||
override func setUpWithError() throws {
|
override func setUpWithError() throws {
|
||||||
try super.setUpWithError()
|
try super.setUpWithError()
|
||||||
|
Task{ @MainActor [self] in
|
||||||
coordinator = try TestCoordinator(
|
self.coordinator = try await TestCoordinator(
|
||||||
seed: seedPhrase,
|
seed: seedPhrase,
|
||||||
walletBirthday: birthday,
|
walletBirthday: birthday,
|
||||||
channelProvider: ChannelProvider(),
|
channelProvider: ChannelProvider(),
|
||||||
network: network
|
network: network
|
||||||
)
|
)
|
||||||
|
}
|
||||||
try coordinator.reset(saplingActivation: 663150, branchID: "e9ff75a6", chainName: "main")
|
try coordinator.reset(saplingActivation: 663150, branchID: "e9ff75a6", chainName: "main")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,12 +30,14 @@ class ShieldFundsTests: XCTestCase {
|
||||||
|
|
||||||
override func setUpWithError() throws {
|
override func setUpWithError() throws {
|
||||||
try super.setUpWithError()
|
try super.setUpWithError()
|
||||||
coordinator = try TestCoordinator(
|
Task { @MainActor [self] in
|
||||||
|
self.coordinator = try await TestCoordinator(
|
||||||
seed: seedPhrase,
|
seed: seedPhrase,
|
||||||
walletBirthday: birthday,
|
walletBirthday: birthday,
|
||||||
channelProvider: ChannelProvider(),
|
channelProvider: ChannelProvider(),
|
||||||
network: network
|
network: network
|
||||||
)
|
)
|
||||||
|
}
|
||||||
try coordinator.reset(saplingActivation: birthday, branchID: self.branchID, chainName: self.chainName)
|
try coordinator.reset(saplingActivation: birthday, branchID: self.branchID, chainName: self.chainName)
|
||||||
try coordinator.service.clearAddedUTXOs()
|
try coordinator.service.clearAddedUTXOs()
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,12 +34,14 @@ class SychronizerDarksideTests: XCTestCase {
|
||||||
|
|
||||||
override func setUpWithError() throws {
|
override func setUpWithError() throws {
|
||||||
try super.setUpWithError()
|
try super.setUpWithError()
|
||||||
coordinator = try TestCoordinator(
|
Task{ @MainActor [self] in
|
||||||
|
coordinator = try await TestCoordinator(
|
||||||
seed: seedPhrase,
|
seed: seedPhrase,
|
||||||
walletBirthday: birthday,
|
walletBirthday: birthday,
|
||||||
channelProvider: ChannelProvider(),
|
channelProvider: ChannelProvider(),
|
||||||
network: network
|
network: network
|
||||||
)
|
)
|
||||||
|
}
|
||||||
try coordinator.reset(saplingActivation: 663150, branchID: "e9ff75a6", chainName: "main")
|
try coordinator.reset(saplingActivation: 663150, branchID: "e9ff75a6", chainName: "main")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,12 +34,15 @@ final class SynchronizerTests: XCTestCase {
|
||||||
|
|
||||||
override func setUpWithError() throws {
|
override func setUpWithError() throws {
|
||||||
try super.setUpWithError()
|
try super.setUpWithError()
|
||||||
coordinator = try TestCoordinator(
|
Task { @MainActor [self] in
|
||||||
|
coordinator = try await TestCoordinator(
|
||||||
seed: seedPhrase,
|
seed: seedPhrase,
|
||||||
walletBirthday: birthday + 50, //don't use an exact birthday, users never do.
|
walletBirthday: birthday + 50, //don't use an exact birthday, users never do.
|
||||||
channelProvider: ChannelProvider(),
|
channelProvider: ChannelProvider(),
|
||||||
network: network
|
network: network
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
try coordinator.reset(saplingActivation: 663150, branchID: self.branchID, chainName: self.chainName)
|
try coordinator.reset(saplingActivation: 663150, branchID: self.branchID, chainName: self.chainName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,10 +147,10 @@ class TransactionEnhancementTests: XCTestCase {
|
||||||
|
|
||||||
txFoundNotificationExpectation.subscribe(to: .blockProcessorFoundTransactions, object: processor)
|
txFoundNotificationExpectation.subscribe(to: .blockProcessorFoundTransactions, object: processor)
|
||||||
idleNotificationExpectation.subscribe(to: .blockProcessorIdle, object: processor)
|
idleNotificationExpectation.subscribe(to: .blockProcessorIdle, object: processor)
|
||||||
try await processor.start()
|
await processor.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
func testBasicEnhacement() throws {
|
func testBasicEnhacement() async throws {
|
||||||
let targetLatestHeight = BlockHeight(663200)
|
let targetLatestHeight = BlockHeight(663200)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -31,12 +31,14 @@ class Z2TReceiveTests: XCTestCase {
|
||||||
override func setUpWithError() throws {
|
override func setUpWithError() throws {
|
||||||
try super.setUpWithError()
|
try super.setUpWithError()
|
||||||
|
|
||||||
coordinator = try TestCoordinator(
|
Task{ @MainActor [self] in
|
||||||
|
coordinator = try await TestCoordinator(
|
||||||
seed: seedPhrase,
|
seed: seedPhrase,
|
||||||
walletBirthday: birthday,
|
walletBirthday: birthday,
|
||||||
channelProvider: ChannelProvider(),
|
channelProvider: ChannelProvider(),
|
||||||
network: network
|
network: network
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
try coordinator.reset(saplingActivation: 663150, branchID: self.branchID, chainName: self.chainName)
|
try coordinator.reset(saplingActivation: 663150, branchID: self.branchID, chainName: self.chainName)
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,10 @@ class CompactBlockReorgTests: XCTestCase {
|
||||||
info.saplingActivationHeight = UInt64(network.constants.saplingActivationHeight)
|
info.saplingActivationHeight = UInt64(network.constants.saplingActivationHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
try ZcashRustBackend.initDataDb(dbData: processorConfig.dataDb, networkType: .testnet)
|
guard case .success = try ZcashRustBackend.initDataDb(dbData: processorConfig.dataDb, seed: nil, networkType: .testnet) else {
|
||||||
|
XCTFail("initDataDb failed. Expected Success but got .seedRequired")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let storage = CompactBlockStorage.init(connectionProvider: SimpleConnectionProvider(path: processorConfig.cacheDb.absoluteString))
|
let storage = CompactBlockStorage.init(connectionProvider: SimpleConnectionProvider(path: processorConfig.cacheDb.absoluteString))
|
||||||
try! storage.createTable()
|
try! storage.createTable()
|
||||||
|
@ -139,11 +142,7 @@ class CompactBlockReorgTests: XCTestCase {
|
||||||
idleNotificationExpectation.subscribe(to: Notification.Name.blockProcessorFinished, object: processor)
|
idleNotificationExpectation.subscribe(to: Notification.Name.blockProcessorFinished, object: processor)
|
||||||
reorgNotificationExpectation.subscribe(to: Notification.Name.blockProcessorHandledReOrg, object: processor)
|
reorgNotificationExpectation.subscribe(to: Notification.Name.blockProcessorHandledReOrg, object: processor)
|
||||||
|
|
||||||
do {
|
await processor.start()
|
||||||
try await processor.start()
|
|
||||||
} catch {
|
|
||||||
XCTFail("shouldn't fail")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testNotifiesReorg() async {
|
func testNotifiesReorg() async {
|
||||||
|
|
|
@ -51,10 +51,8 @@ class WalletTests: XCTestCase {
|
||||||
|
|
||||||
let synchronizer = try SDKSynchronizer(initializer: wallet)
|
let synchronizer = try SDKSynchronizer(initializer: wallet)
|
||||||
do {
|
do {
|
||||||
try await synchronizer.prepare()
|
guard case .success = try await synchronizer.prepare(with: seedData.bytes) else {
|
||||||
|
XCTFail("Failed to initDataDb. Expected `.success` got: `.seedRequired`")
|
||||||
guard case .success = dbInit else {
|
|
||||||
XCTFail("Failed to initDataDb. Expected `.success` got: \(String(describing: dbInit))")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
@ -50,7 +50,7 @@ class TestCoordinator {
|
||||||
walletBirthday: BlockHeight,
|
walletBirthday: BlockHeight,
|
||||||
channelProvider: ChannelProvider,
|
channelProvider: ChannelProvider,
|
||||||
network: ZcashNetwork
|
network: ZcashNetwork
|
||||||
) throws {
|
) async throws {
|
||||||
let derivationTool = DerivationTool(networkType: network.networkType)
|
let derivationTool = DerivationTool(networkType: network.networkType)
|
||||||
|
|
||||||
let spendingKey = try derivationTool.deriveUnifiedSpendingKey(
|
let spendingKey = try derivationTool.deriveUnifiedSpendingKey(
|
||||||
|
@ -60,7 +60,7 @@ class TestCoordinator {
|
||||||
|
|
||||||
let ufvk = try derivationTool.deriveUnifiedFullViewingKey(from: spendingKey)
|
let ufvk = try derivationTool.deriveUnifiedFullViewingKey(from: spendingKey)
|
||||||
|
|
||||||
try self.init(
|
await try self.init(
|
||||||
spendingKey: spendingKey,
|
spendingKey: spendingKey,
|
||||||
unifiedFullViewingKey: ufvk,
|
unifiedFullViewingKey: ufvk,
|
||||||
walletBirthday: walletBirthday,
|
walletBirthday: walletBirthday,
|
||||||
|
@ -75,7 +75,7 @@ class TestCoordinator {
|
||||||
walletBirthday: BlockHeight,
|
walletBirthday: BlockHeight,
|
||||||
channelProvider: ChannelProvider,
|
channelProvider: ChannelProvider,
|
||||||
network: ZcashNetwork
|
network: ZcashNetwork
|
||||||
) throws {
|
) async throws {
|
||||||
self.spendingKey = spendingKey
|
self.spendingKey = spendingKey
|
||||||
self.birthday = walletBirthday
|
self.birthday = walletBirthday
|
||||||
self.channelProvider = channelProvider
|
self.channelProvider = channelProvider
|
||||||
|
@ -93,7 +93,7 @@ class TestCoordinator {
|
||||||
let storage = CompactBlockStorage(url: databases.cacheDB, readonly: false)
|
let storage = CompactBlockStorage(url: databases.cacheDB, readonly: false)
|
||||||
try storage.createTable()
|
try storage.createTable()
|
||||||
|
|
||||||
let buildResult = try TestSynchronizerBuilder.build(
|
let buildResult = try await TestSynchronizerBuilder.build(
|
||||||
rustBackend: ZcashRustBackend.self,
|
rustBackend: ZcashRustBackend.self,
|
||||||
lowerBoundHeight: self.birthday,
|
lowerBoundHeight: self.birthday,
|
||||||
cacheDbURL: databases.cacheDB,
|
cacheDbURL: databases.cacheDB,
|
||||||
|
@ -291,7 +291,7 @@ enum TestSynchronizerBuilder {
|
||||||
network: ZcashNetwork,
|
network: ZcashNetwork,
|
||||||
seed: [UInt8]? = nil,
|
seed: [UInt8]? = nil,
|
||||||
loggerProxy: Logger? = nil
|
loggerProxy: Logger? = nil
|
||||||
) throws -> (spendingKeys: [UnifiedSpendingKey]?, synchronizer: SDKSynchronizer) {
|
) async throws -> (spendingKeys: [UnifiedSpendingKey]?, synchronizer: SDKSynchronizer) {
|
||||||
let initializer = Initializer(
|
let initializer = Initializer(
|
||||||
cacheDbURL: cacheDbURL,
|
cacheDbURL: cacheDbURL,
|
||||||
dataDbURL: dataDbURL,
|
dataDbURL: dataDbURL,
|
||||||
|
@ -331,7 +331,7 @@ enum TestSynchronizerBuilder {
|
||||||
walletBirthday: BlockHeight,
|
walletBirthday: BlockHeight,
|
||||||
network: ZcashNetwork,
|
network: ZcashNetwork,
|
||||||
loggerProxy: Logger? = nil
|
loggerProxy: Logger? = nil
|
||||||
) throws -> (spendingKeys: [UnifiedSpendingKey]?, synchronizer: SDKSynchronizer) {
|
) async throws -> (spendingKeys: [UnifiedSpendingKey]?, synchronizer: SDKSynchronizer) {
|
||||||
let spendingKey = try DerivationTool(networkType: network.networkType)
|
let spendingKey = try DerivationTool(networkType: network.networkType)
|
||||||
.deriveUnifiedSpendingKey(seed: seedBytes, accountIndex: 0)
|
.deriveUnifiedSpendingKey(seed: seedBytes, accountIndex: 0)
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ enum TestSynchronizerBuilder {
|
||||||
let uvk = try DerivationTool(networkType: network.networkType)
|
let uvk = try DerivationTool(networkType: network.networkType)
|
||||||
.deriveUnifiedFullViewingKey(from: spendingKey)
|
.deriveUnifiedFullViewingKey(from: spendingKey)
|
||||||
|
|
||||||
return try build(
|
return try await build(
|
||||||
rustBackend: rustBackend,
|
rustBackend: rustBackend,
|
||||||
lowerBoundHeight: lowerBoundHeight,
|
lowerBoundHeight: lowerBoundHeight,
|
||||||
cacheDbURL: cacheDbURL,
|
cacheDbURL: cacheDbURL,
|
||||||
|
|
Loading…
Reference in New Issue