Skip to content

Commit

Permalink
remove pending proofs public method
Browse files Browse the repository at this point in the history
  • Loading branch information
elnosh committed Oct 28, 2024
1 parent 2a875c2 commit 1be3a85
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 30 deletions.
8 changes: 2 additions & 6 deletions wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
34 changes: 10 additions & 24 deletions wallet/wallet_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}

Expand All @@ -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 {
Expand All @@ -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)
Expand Down

0 comments on commit 1be3a85

Please sign in to comment.