diff --git a/wallet/wallet.go b/wallet/wallet.go index 0847ca4..1fa76e1 100644 --- a/wallet/wallet.go +++ b/wallet/wallet.go @@ -321,10 +321,10 @@ func (w *Wallet) GetBalanceByMints() map[string]uint64 { } func (w *Wallet) PendingBalance() uint64 { - return Amount(w.db.GetPendingProofs()) + return amount(w.db.GetPendingProofs()) } -func Amount(proofs []storage.DBProof) uint64 { +func amount(proofs []storage.DBProof) uint64 { var totalAmount uint64 = 0 for _, proof := range proofs { totalAmount += proof.Amount @@ -1939,10 +1939,6 @@ func Restore(walletPath, mnemonic string, mintsToRestore []string) (cashu.Proofs return proofsRestored, nil } -func (w *Wallet) GetPendingProofs() []storage.DBProof { - return w.db.GetPendingProofs() -} - // GetPendingMeltQuotes return a list of pending quote ids func (w *Wallet) GetPendingMeltQuotes() []string { pendingProofs := w.db.GetPendingProofs() diff --git a/wallet/wallet_integration_test.go b/wallet/wallet_integration_test.go index 1ffd42a..624cb80 100644 --- a/wallet/wallet_integration_test.go +++ b/wallet/wallet_integration_test.go @@ -637,13 +637,7 @@ func TestPendingProofs(t *testing.T) { t.Fatalf("expected quote state of '%s' but got '%s' instead", nut05.Pending, meltQuote.State) } - // check amount of pending proofs is same as quote amount - pendingProofsAmount := wallet.Amount(testWallet.GetPendingProofs()) - expectedAmount := meltQuote.Amount + meltQuote.FeeReserve - if pendingProofsAmount != expectedAmount { - t.Fatalf("expected amount of pending proofs of '%v' but got '%v' instead", - expectedAmount, pendingProofsAmount) - } + // check pending balance is same as quote amount pendingBalance := testWallet.PendingBalance() expectedPendingBalance := meltQuote.Amount + meltQuote.FeeReserve if pendingBalance != expectedPendingBalance { @@ -677,13 +671,8 @@ func TestPendingProofs(t *testing.T) { nut05.Paid, meltQuoteStateResponse.State) } - // check no pending proofs or pending balance after settling and checking melt quote state - pendingProofsAmount = wallet.Amount(testWallet.GetPendingProofs()) - if pendingProofsAmount != 0 { - t.Fatalf("expected no pending proofs amount but got '%v' instead", pendingProofsAmount) - } - pendingBalance = testWallet.PendingBalance() - if pendingBalance != 0 { + // check no pending balance after settling and checking melt quote state + if testWallet.PendingBalance() != 0 { t.Fatalf("expected no pending balance but got '%v' instead", pendingBalance) } @@ -709,11 +698,12 @@ func TestPendingProofs(t *testing.T) { if meltQuote.State != nut05.Pending { t.Fatalf("expected quote state of '%s' but got '%s' instead", nut05.Pending, meltQuote.State) } - pendingProofsAmount = wallet.Amount(testWallet.GetPendingProofs()) - expectedAmount = meltQuote.Amount + meltQuote.FeeReserve - if pendingProofsAmount != expectedAmount { - t.Fatalf("expected amount of pending proofs of '%v' but got '%v' instead", - expectedAmount, pendingProofsAmount) + + pendingBalance = testWallet.PendingBalance() + expectedPendingBalance = meltQuote.Amount + meltQuote.FeeReserve + if testWallet.PendingBalance() != expectedPendingBalance { + t.Fatalf("expected pending balance of '%v' but got '%v' instead", + expectedPendingBalance, pendingBalance) } pendingMeltQuotes = testWallet.GetPendingMeltQuotes() if len(pendingMeltQuotes) != 1 { @@ -735,11 +725,7 @@ func TestPendingProofs(t *testing.T) { nut05.Unpaid, meltQuoteStateResponse.State) } - // check no pending proofs or pending balance after canceling and checking melt quote state - pendingProofsAmount = wallet.Amount(testWallet.GetPendingProofs()) - if pendingProofsAmount != 0 { - t.Fatalf("expected no pending proofs amount but got '%v' instead", pendingProofsAmount) - } + // check no pending balance after canceling and checking melt quote state pendingBalance = testWallet.PendingBalance() if pendingBalance != 0 { t.Fatalf("expected no pending balance but got '%v' instead", pendingBalance)