Update Invoice tests to use the new blocks interface, and fix reverse blocks iteration indexing

Changelog-None
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
Daniel D’Aquino
2025-07-25 18:43:45 -07:00
parent 4036995348
commit f8245a7b0e
3 changed files with 159 additions and 57 deletions

View File

@@ -139,6 +139,15 @@ struct NdbBlockGroup: ~Copyable {
rawTextContent: content
)
}
/// Parses the note contents on-demand from a specific text.
static func parse(content: String) throws(NdbBlocksError) -> Self {
guard let metadata = BlocksMetadata.parseContent(content: content) else { throw NdbBlocksError.parseError }
return self.init(
metadata: .pure(metadata),
rawTextContent: content
)
}
}
enum MaybeTxn<T: ~Copyable>: ~Copyable {

View File

@@ -38,7 +38,7 @@ struct NonCopyableLinkedList<T: ~Copyable>: ~Copyable {
/// Iterates over each item of the list in reverse, with enumeration support.
func forEachItemReversed<Y, E: Error>(_ borrowingFunction: ((_ index: Int, _ item: borrowing T) throws(E) -> LoopCommand<Y>)) throws(E) -> Y? {
var indexCounter = count
var indexCounter = count - 1
var cursor: Node? = self.tail
outerLoop: while let nextItem = cursor {