ScanRange initialization changed

- only the matching priorities are allowed, otherwise fatalError
This commit is contained in:
Lukas Korba 2023-09-13 17:57:24 +02:00
parent 50afc8f2e5
commit 26fe1f7310
2 changed files with 1 additions and 18 deletions

View File

@ -18,18 +18,10 @@ struct ScanRange {
case verify = 60
init(_ value: UInt8) {
// the given priority matches the values
if let priority = Priority(rawValue: value) {
self = priority
} else {
// no match found, getting the one above the value
let valueNeeded = (value / 10) * 10 + 10
if let priority = Priority(rawValue: valueNeeded) {
self = priority
} else {
fatalError("The value \(value) is out of the range of priorities.")
}
fatalError("The value \(value) is out of the range of priorities.")
}
}
}

View File

@ -140,7 +140,6 @@ final class ProcessSuggestedScanRangesActionTests: ZcashTestCase {
}
func testScanRangePriorities() {
// matching priorities
XCTAssertEqual(ScanRange.Priority(0), .ignored)
XCTAssertEqual(ScanRange.Priority(10), .scanned)
XCTAssertEqual(ScanRange.Priority(20), .historic)
@ -148,13 +147,5 @@ final class ProcessSuggestedScanRangesActionTests: ZcashTestCase {
XCTAssertEqual(ScanRange.Priority(40), .foundNote)
XCTAssertEqual(ScanRange.Priority(50), .chainTip)
XCTAssertEqual(ScanRange.Priority(60), .verify)
// custom priorities
XCTAssertEqual(ScanRange.Priority(4), .scanned)
XCTAssertEqual(ScanRange.Priority(14), .historic)
XCTAssertEqual(ScanRange.Priority(24), .openAdjacent)
XCTAssertEqual(ScanRange.Priority(34), .foundNote)
XCTAssertEqual(ScanRange.Priority(44), .chainTip)
XCTAssertEqual(ScanRange.Priority(54), .verify)
}
}