[#700] Fix progress reporting
Some actions in the sync process may not run. For example there are no transactions to enhance and therefore there is no enhance progress. And in cases like this computation of final progress won't work properly. So let's fake 100% progress at the end of the sync process.
This commit is contained in:
parent
2797f7be2d
commit
29acc0c893
|
@ -74,6 +74,7 @@ extension EnhanceAction: Action {
|
|||
didEnhance: { progress in
|
||||
if let foundTx = progress.lastFoundTransaction, progress.newlyMined {
|
||||
await didUpdate(.minedTransaction(foundTx))
|
||||
await didUpdate(.progressPartialUpdate(.enhance(progress)))
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
@ -631,6 +631,9 @@ extension CompactBlockProcessor {
|
|||
consecutiveChainValidationErrors = 0
|
||||
|
||||
let lastScannedHeight = await latestBlocksDataProvider.latestScannedHeight
|
||||
// Some actions may not run. For example there are no transactions to enhance and therefore there is no enhance progress. And in
|
||||
// cases like this computation of final progress won't work properly. So let's fake 100% progress at the end of the sync process.
|
||||
await send(event: .progressUpdated(1))
|
||||
await send(event: .finished(lastScannedHeight))
|
||||
await context.update(state: .finished)
|
||||
|
||||
|
|
|
@ -1332,7 +1332,7 @@ class AdvancedReOrgTests: ZcashTestCase {
|
|||
XCTAssertEqual(expectedBalance, initialTotalBalance)
|
||||
}
|
||||
|
||||
func asdastestLongSync() async throws {
|
||||
func testLongSync() async throws {
|
||||
await hookToReOrgNotification()
|
||||
|
||||
/*
|
||||
|
|
|
@ -209,6 +209,15 @@ class SynchronizerDarksideTests: ZcashTestCase {
|
|||
latestBlockHeight: 663189,
|
||||
latestScannedTime: 1
|
||||
),
|
||||
SynchronizerState(
|
||||
syncSessionID: uuids[0],
|
||||
shieldedBalance: WalletBalance(verified: Zatoshi(100000), total: Zatoshi(200000)),
|
||||
transparentBalance: .zero,
|
||||
internalSyncStatus: .syncing(1.0),
|
||||
latestScannedHeight: 663189,
|
||||
latestBlockHeight: 663189,
|
||||
latestScannedTime: 1
|
||||
),
|
||||
SynchronizerState(
|
||||
syncSessionID: uuids[0],
|
||||
shieldedBalance: WalletBalance(verified: Zatoshi(100000), total: Zatoshi(200000)),
|
||||
|
@ -287,6 +296,15 @@ class SynchronizerDarksideTests: ZcashTestCase {
|
|||
latestBlockHeight: 663189,
|
||||
latestScannedTime: 1
|
||||
),
|
||||
SynchronizerState(
|
||||
syncSessionID: uuids[0],
|
||||
shieldedBalance: WalletBalance(verified: Zatoshi(100000), total: Zatoshi(200000)),
|
||||
transparentBalance: .zero,
|
||||
internalSyncStatus: .syncing(1.0),
|
||||
latestScannedHeight: 663189,
|
||||
latestBlockHeight: 663189,
|
||||
latestScannedTime: 1
|
||||
),
|
||||
SynchronizerState(
|
||||
syncSessionID: uuids[0],
|
||||
shieldedBalance: WalletBalance(verified: Zatoshi(100000), total: Zatoshi(200000)),
|
||||
|
@ -341,6 +359,15 @@ class SynchronizerDarksideTests: ZcashTestCase {
|
|||
latestBlockHeight: 663200,
|
||||
latestScannedTime: 1
|
||||
),
|
||||
SynchronizerState(
|
||||
syncSessionID: uuids[1],
|
||||
shieldedBalance: WalletBalance(verified: Zatoshi(200000), total: Zatoshi(200000)),
|
||||
transparentBalance: WalletBalance(verified: Zatoshi(0), total: Zatoshi(0)),
|
||||
internalSyncStatus: .syncing(1.0),
|
||||
latestScannedHeight: 663200,
|
||||
latestBlockHeight: 663200,
|
||||
latestScannedTime: 1
|
||||
),
|
||||
SynchronizerState(
|
||||
syncSessionID: uuids[1],
|
||||
shieldedBalance: WalletBalance(verified: Zatoshi(200000), total: Zatoshi(200000)),
|
||||
|
|
|
@ -232,6 +232,8 @@ final class EnhanceActionTests: ZcashTestCase {
|
|||
|
||||
do {
|
||||
_ = try await enhanceAction.run(with: syncContext) { event in
|
||||
if case .progressPartialUpdate = event { return }
|
||||
|
||||
guard case .minedTransaction(let minedTransaction) = event else {
|
||||
XCTFail("Event is expected to be .minedTransaction but received \(event)")
|
||||
return
|
||||
|
@ -297,6 +299,8 @@ final class EnhanceActionTests: ZcashTestCase {
|
|||
|
||||
do {
|
||||
_ = try await enhanceAction.run(with: syncContext) { event in
|
||||
if case .progressPartialUpdate = event { return }
|
||||
|
||||
guard case .minedTransaction(let minedTransaction) = event else {
|
||||
XCTFail("Event is expected to be .minedTransaction but received \(event)")
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue