The code below is a fragment of a service that assembles a text preview of invoice lines and marks publication in shared state. After a recent PR, the behavior started diverging from what is expected: some unsuccessful scenarios look like a successful operation, and the state may change even when an error occurs.
publish_preview must read invoice lines by identifiers from InvoiceStore in the order they are passed.Err, without returning a partial success result.published counter in PublishState must increase only after the entire preview has been built successfully." | ".cargo test
published value must not change.published must increase by exactly 1 per call.1.85.02021cargo testInvoiceStore::publish_preview(&self, ids: &[u64], state: &Mutex<PublishState>) -> Result<String, PreviewError>InvoiceStore is considered an error for the whole operationUse line comments to explain the problem, its impact, the fix and how to test it.