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))
|
||||
case .downloading, .validating, .scanning, .enhancing, .fetching:
|
||||
LoggerProxy.debug("Warning: compact block processor was started while busy!!!!")
|
||||
needsToStartScanningWhenStopped.set(true)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -1000,9 +999,6 @@ extension CompactBlockProcessor {
|
|||
guard accountIndex >= 0 else {
|
||||
throw CompactBlockProcessorError.invalidAccount
|
||||
}
|
||||
return try utxoCacheBalance(tAddress: tAddress)
|
||||
}
|
||||
}
|
||||
|
||||
return WalletBalance(
|
||||
verified: Zatoshi(
|
||||
|
|
|
@ -93,7 +93,7 @@ public protocol Synchronizer {
|
|||
/// 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.
|
||||
/// - 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.
|
||||
/// - 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
|
||||
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()
|
||||
|
||||
var height: BlockHeight?
|
||||
|
|
|
@ -34,12 +34,14 @@ class AdvancedReOrgTests: XCTestCase {
|
|||
|
||||
override func setUpWithError() throws {
|
||||
try super.setUpWithError()
|
||||
coordinator = try TestCoordinator(
|
||||
Task{ @MainActor [self] in
|
||||
self.coordinator = try await TestCoordinator(
|
||||
seed: seedPhrase,
|
||||
walletBirthday: birthday + 50, //don't use an exact birthday, users never do.
|
||||
channelProvider: ChannelProvider(),
|
||||
network: network
|
||||
)
|
||||
}
|
||||
try coordinator.reset(saplingActivation: 663150, branchID: self.branchID, chainName: self.chainName)
|
||||
}
|
||||
|
||||
|
|
|
@ -30,12 +30,14 @@ class BalanceTests: XCTestCase {
|
|||
|
||||
override func setUpWithError() throws {
|
||||
try super.setUpWithError()
|
||||
coordinator = try TestCoordinator(
|
||||
Task{ @MainActor [self] in
|
||||
self.coordinator = try await TestCoordinator(
|
||||
seed: seedPhrase,
|
||||
walletBirthday: birthday,
|
||||
channelProvider: ChannelProvider(),
|
||||
network: network
|
||||
)
|
||||
}
|
||||
try coordinator.reset(saplingActivation: 663150, branchID: "e9ff75a6", chainName: "main")
|
||||
}
|
||||
|
||||
|
|
|
@ -33,12 +33,14 @@ class DarksideSanityCheckTests: XCTestCase {
|
|||
|
||||
override func setUpWithError() throws {
|
||||
try super.setUpWithError()
|
||||
coordinator = try TestCoordinator(
|
||||
Task { @MainActor [self] in
|
||||
self.coordinator = try await TestCoordinator(
|
||||
seed: seedPhrase,
|
||||
walletBirthday: birthday,
|
||||
channelProvider: ChannelProvider(),
|
||||
network: network
|
||||
)
|
||||
}
|
||||
try coordinator.reset(saplingActivation: birthday, branchID: branchID, chainName: chainName)
|
||||
try coordinator.resetBlocks(dataset: .default)
|
||||
}
|
||||
|
|
|
@ -31,12 +31,15 @@ class PendingTransactionUpdatesTest: XCTestCase {
|
|||
let network = DarksideWalletDNetwork()
|
||||
override func setUpWithError() throws {
|
||||
try super.setUpWithError()
|
||||
coordinator = try TestCoordinator(
|
||||
Task{ @MainActor in
|
||||
coordinator = try await TestCoordinator(
|
||||
seed: seedPhrase,
|
||||
walletBirthday: birthday,
|
||||
channelProvider: ChannelProvider(),
|
||||
network: network
|
||||
)
|
||||
}
|
||||
|
||||
try coordinator.reset(saplingActivation: 663150, branchID: "e9ff75a6", chainName: "main")
|
||||
}
|
||||
|
||||
|
|
|
@ -47,18 +47,23 @@ class ReOrgTests: XCTestCase {
|
|||
|
||||
override func setUpWithError() throws {
|
||||
try super.setUpWithError()
|
||||
|
||||
NotificationCenter.default.addObserver(
|
||||
self,
|
||||
selector: #selector(handleReOrgNotification(_:)),
|
||||
name: Notification.Name.blockProcessorHandledReOrg,
|
||||
object: nil
|
||||
)
|
||||
coordinator = try TestCoordinator(
|
||||
|
||||
Task{ @MainActor [self] in
|
||||
coordinator = try await TestCoordinator(
|
||||
seed: seedPhrase,
|
||||
walletBirthday: birthday,
|
||||
channelProvider: ChannelProvider(),
|
||||
network: network
|
||||
)
|
||||
}
|
||||
|
||||
try coordinator.reset(saplingActivation: birthday, branchID: branchID, chainName: chainName)
|
||||
try coordinator.resetBlocks(dataset: .default)
|
||||
}
|
||||
|
|
|
@ -34,14 +34,14 @@ class RewindRescanTests: XCTestCase {
|
|||
|
||||
override func setUpWithError() throws {
|
||||
try super.setUpWithError()
|
||||
|
||||
coordinator = try TestCoordinator(
|
||||
Task{ @MainActor [self] in
|
||||
self.coordinator = try await TestCoordinator(
|
||||
seed: seedPhrase,
|
||||
walletBirthday: birthday,
|
||||
channelProvider: ChannelProvider(),
|
||||
network: network
|
||||
)
|
||||
|
||||
}
|
||||
try coordinator.reset(saplingActivation: 663150, branchID: "e9ff75a6", chainName: "main")
|
||||
}
|
||||
|
||||
|
|
|
@ -30,12 +30,14 @@ class ShieldFundsTests: XCTestCase {
|
|||
|
||||
override func setUpWithError() throws {
|
||||
try super.setUpWithError()
|
||||
coordinator = try TestCoordinator(
|
||||
Task { @MainActor [self] in
|
||||
self.coordinator = try await TestCoordinator(
|
||||
seed: seedPhrase,
|
||||
walletBirthday: birthday,
|
||||
channelProvider: ChannelProvider(),
|
||||
network: network
|
||||
)
|
||||
}
|
||||
try coordinator.reset(saplingActivation: birthday, branchID: self.branchID, chainName: self.chainName)
|
||||
try coordinator.service.clearAddedUTXOs()
|
||||
}
|
||||
|
|
|
@ -34,12 +34,14 @@ class SychronizerDarksideTests: XCTestCase {
|
|||
|
||||
override func setUpWithError() throws {
|
||||
try super.setUpWithError()
|
||||
coordinator = try TestCoordinator(
|
||||
Task{ @MainActor [self] in
|
||||
coordinator = try await TestCoordinator(
|
||||
seed: seedPhrase,
|
||||
walletBirthday: birthday,
|
||||
channelProvider: ChannelProvider(),
|
||||
network: network
|
||||
)
|
||||
}
|
||||
try coordinator.reset(saplingActivation: 663150, branchID: "e9ff75a6", chainName: "main")
|
||||
}
|
||||
|
||||
|
|
|
@ -34,12 +34,15 @@ final class SynchronizerTests: XCTestCase {
|
|||
|
||||
override func setUpWithError() throws {
|
||||
try super.setUpWithError()
|
||||
coordinator = try TestCoordinator(
|
||||
Task { @MainActor [self] in
|
||||
coordinator = try await TestCoordinator(
|
||||
seed: seedPhrase,
|
||||
walletBirthday: birthday + 50, //don't use an exact birthday, users never do.
|
||||
channelProvider: ChannelProvider(),
|
||||
network: network
|
||||
)
|
||||
}
|
||||
|
||||
try coordinator.reset(saplingActivation: 663150, branchID: self.branchID, chainName: self.chainName)
|
||||
}
|
||||
|
||||
|
|
|
@ -147,10 +147,10 @@ class TransactionEnhancementTests: XCTestCase {
|
|||
|
||||
txFoundNotificationExpectation.subscribe(to: .blockProcessorFoundTransactions, 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)
|
||||
|
||||
do {
|
||||
|
|
|
@ -31,12 +31,14 @@ class Z2TReceiveTests: XCTestCase {
|
|||
override func setUpWithError() throws {
|
||||
try super.setUpWithError()
|
||||
|
||||
coordinator = try TestCoordinator(
|
||||
Task{ @MainActor [self] in
|
||||
coordinator = try await TestCoordinator(
|
||||
seed: seedPhrase,
|
||||
walletBirthday: birthday,
|
||||
channelProvider: ChannelProvider(),
|
||||
network: network
|
||||
)
|
||||
}
|
||||
|
||||
try coordinator.reset(saplingActivation: 663150, branchID: self.branchID, chainName: self.chainName)
|
||||
}
|
||||
|
|
|
@ -47,7 +47,10 @@ class CompactBlockReorgTests: XCTestCase {
|
|||
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))
|
||||
try! storage.createTable()
|
||||
|
@ -139,11 +142,7 @@ class CompactBlockReorgTests: XCTestCase {
|
|||
idleNotificationExpectation.subscribe(to: Notification.Name.blockProcessorFinished, object: processor)
|
||||
reorgNotificationExpectation.subscribe(to: Notification.Name.blockProcessorHandledReOrg, object: processor)
|
||||
|
||||
do {
|
||||
try await processor.start()
|
||||
} catch {
|
||||
XCTFail("shouldn't fail")
|
||||
}
|
||||
await processor.start()
|
||||
}
|
||||
|
||||
func testNotifiesReorg() async {
|
||||
|
|
|
@ -51,10 +51,8 @@ class WalletTests: XCTestCase {
|
|||
|
||||
let synchronizer = try SDKSynchronizer(initializer: wallet)
|
||||
do {
|
||||
try await synchronizer.prepare()
|
||||
|
||||
guard case .success = dbInit else {
|
||||
XCTFail("Failed to initDataDb. Expected `.success` got: \(String(describing: dbInit))")
|
||||
guard case .success = try await synchronizer.prepare(with: seedData.bytes) else {
|
||||
XCTFail("Failed to initDataDb. Expected `.success` got: `.seedRequired`")
|
||||
return
|
||||
}
|
||||
} catch {
|
||||
|
|
|
@ -50,7 +50,7 @@ class TestCoordinator {
|
|||
walletBirthday: BlockHeight,
|
||||
channelProvider: ChannelProvider,
|
||||
network: ZcashNetwork
|
||||
) throws {
|
||||
) async throws {
|
||||
let derivationTool = DerivationTool(networkType: network.networkType)
|
||||
|
||||
let spendingKey = try derivationTool.deriveUnifiedSpendingKey(
|
||||
|
@ -60,7 +60,7 @@ class TestCoordinator {
|
|||
|
||||
let ufvk = try derivationTool.deriveUnifiedFullViewingKey(from: spendingKey)
|
||||
|
||||
try self.init(
|
||||
await try self.init(
|
||||
spendingKey: spendingKey,
|
||||
unifiedFullViewingKey: ufvk,
|
||||
walletBirthday: walletBirthday,
|
||||
|
@ -75,7 +75,7 @@ class TestCoordinator {
|
|||
walletBirthday: BlockHeight,
|
||||
channelProvider: ChannelProvider,
|
||||
network: ZcashNetwork
|
||||
) throws {
|
||||
) async throws {
|
||||
self.spendingKey = spendingKey
|
||||
self.birthday = walletBirthday
|
||||
self.channelProvider = channelProvider
|
||||
|
@ -93,7 +93,7 @@ class TestCoordinator {
|
|||
let storage = CompactBlockStorage(url: databases.cacheDB, readonly: false)
|
||||
try storage.createTable()
|
||||
|
||||
let buildResult = try TestSynchronizerBuilder.build(
|
||||
let buildResult = try await TestSynchronizerBuilder.build(
|
||||
rustBackend: ZcashRustBackend.self,
|
||||
lowerBoundHeight: self.birthday,
|
||||
cacheDbURL: databases.cacheDB,
|
||||
|
@ -291,7 +291,7 @@ enum TestSynchronizerBuilder {
|
|||
network: ZcashNetwork,
|
||||
seed: [UInt8]? = nil,
|
||||
loggerProxy: Logger? = nil
|
||||
) throws -> (spendingKeys: [UnifiedSpendingKey]?, synchronizer: SDKSynchronizer) {
|
||||
) async throws -> (spendingKeys: [UnifiedSpendingKey]?, synchronizer: SDKSynchronizer) {
|
||||
let initializer = Initializer(
|
||||
cacheDbURL: cacheDbURL,
|
||||
dataDbURL: dataDbURL,
|
||||
|
@ -331,7 +331,7 @@ enum TestSynchronizerBuilder {
|
|||
walletBirthday: BlockHeight,
|
||||
network: ZcashNetwork,
|
||||
loggerProxy: Logger? = nil
|
||||
) throws -> (spendingKeys: [UnifiedSpendingKey]?, synchronizer: SDKSynchronizer) {
|
||||
) async throws -> (spendingKeys: [UnifiedSpendingKey]?, synchronizer: SDKSynchronizer) {
|
||||
let spendingKey = try DerivationTool(networkType: network.networkType)
|
||||
.deriveUnifiedSpendingKey(seed: seedBytes, accountIndex: 0)
|
||||
|
||||
|
@ -339,7 +339,7 @@ enum TestSynchronizerBuilder {
|
|||
let uvk = try DerivationTool(networkType: network.networkType)
|
||||
.deriveUnifiedFullViewingKey(from: spendingKey)
|
||||
|
||||
return try build(
|
||||
return try await build(
|
||||
rustBackend: rustBackend,
|
||||
lowerBoundHeight: lowerBoundHeight,
|
||||
cacheDbURL: cacheDbURL,
|
||||
|
|
Loading…
Reference in New Issue