ProcessSuggestedScanRanges always continues to the download

- the logic deciding if verify range is present and going to the rewind is no longer valid, so removed
- tests updated
This commit is contained in:
Lukas Korba 2023-09-13 14:58:38 +02:00
parent af595e60e6
commit 3d2812c77f
2 changed files with 3 additions and 33 deletions

View File

@ -62,14 +62,7 @@ extension ProcessSuggestedScanRangesAction: Action {
await context.update(totalProgressRange: minHeight...maxHeight)
}
// If there is a range of blocks that needs to be verified, it will always
// be returned as the first element of the vector of suggested ranges.
if firstRange.priority == .verify {
await context.update(requestedRewindHeight: rangeStartExclusive + 1)
await context.update(state: .rewind)
} else {
await context.update(state: .download)
}
await context.update(state: .download)
} else {
await context.update(state: .finished)
}

View File

@ -80,27 +80,13 @@ final class ProcessSuggestedScanRangesActionTests: ZcashTestCase {
"logger.debug() is not expected to be called."
)
if let nextContextMock = nextContext as? ActionContextMock {
XCTAssertTrue(
nextContextMock.updateRequestedRewindHeightCallsCount == 1,
"context.update(requestedRewindHeight:) is expected to be called exactly once."
)
} else {
XCTFail("`nextContext` is not the ActionContextMock")
}
XCTAssertTrue(
loggerMock.debugFileFunctionLineCalled,
"logger.debug() is not expected to be called."
)
if let infoArguments = loggerMock.infoFileFunctionLineReceivedArguments {
XCTAssertTrue(infoArguments.message.contains("Setting the total range for Spend before Sync to"))
} else {
XCTFail("`infoArguments` unavailable.")
}
let acResult = nextContext.checkStateIs(.rewind)
let acResult = nextContext.checkStateIs(.download)
XCTAssertTrue(acResult == .true, "Check of state failed with '\(acResult)'")
} catch {
XCTFail("testProcessSuggestedScanRangesAction_VerifyScanRangeSetTotalProgressRange is not expected to fail. \(error)")
@ -135,22 +121,13 @@ final class ProcessSuggestedScanRangesActionTests: ZcashTestCase {
"logger.debug() is not expected to be called."
)
if let nextContextMock = nextContext as? ActionContextMock {
XCTAssertTrue(
nextContextMock.updateRequestedRewindHeightCallsCount == 1,
"context.update(requestedRewindHeight:) is expected to be called exactly once."
)
} else {
XCTFail("`nextContext` is not the ActionContextMock")
}
if let infoArguments = loggerMock.infoFileFunctionLineReceivedArguments {
XCTAssertFalse(infoArguments.message.contains("Setting the total range for Spend before Sync to"))
} else {
XCTFail("`infoArguments` unavailable.")
}
let acResult = nextContext.checkStateIs(.rewind)
let acResult = nextContext.checkStateIs(.download)
XCTAssertTrue(acResult == .true, "Check of state failed with '\(acResult)'")
} catch {
XCTFail("testProcessSuggestedScanRangesAction_VerifyScanRangeTotalProgressRangeSkipped is not expected to fail. \(error)")