Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fund9 backport] add additional info in spending counters mismatch errors #826

Open
wants to merge 2 commits into
base: catalyst-fund9
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions chain-impl-mockchain/src/accounting/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ pub enum LedgerError {
AlreadyExists,
#[error("Removed account is not empty")]
NonZero,
#[error("Spending credential invalid")]
SpendingCredentialInvalid,
#[error("Spending credential invalid, expected {} got {} in lane {}", .expected.unlaned_counter(), .actual.unlaned_counter(), .actual.lane())]
SpendingCredentialInvalid {
expected: SpendingCounter,
actual: SpendingCounter,
},
#[error("Value calculation failed")]
ValueError(#[from] ValueError),
}
Expand Down
5 changes: 4 additions & 1 deletion chain-impl-mockchain/src/accounting/account/spending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ impl SpendingCounterIncreasing {
let actual_counter = self.nexts[counter.lane()];

if actual_counter != counter {
Err(LedgerError::SpendingCredentialInvalid)
Err(LedgerError::SpendingCredentialInvalid {
expected: actual_counter,
actual: counter,
})
} else {
self.nexts[counter.lane()] = actual_counter.increment();
Ok(())
Expand Down