Skip to content

Commit

Permalink
pending quote check test
Browse files Browse the repository at this point in the history
  • Loading branch information
lescuer97 committed Nov 4, 2024
1 parent fa4a6b5 commit f1685e4
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions cmd/nutmix/payment_error_handling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,23 @@ func TestPaymentFailureButPendingCheckPaymentMockDbFakeWallet(t *testing.T) {
if proofs[0].State != cashu.PROOF_PENDING {
t.Errorf("Proof should be pending. it is now: %v", proofs[0].State)
}

req = httptest.NewRequest("POST", "/v1/melt/bolt11", strings.NewReader(string(jsonRequestBody)))
w = httptest.NewRecorder()
router.ServeHTTP(w, req)
var errorResponse cashu.ErrorResponse

err = json.Unmarshal(w.Body.Bytes(), &errorResponse)

if err != nil {
t.Fatalf("Could not parse error response %s", w.Body.String())
}

if errorResponse.Code != cashu.QUOTE_PENDING {
t.Errorf("Incorrect error code, got %v", errorResponse.Code)

}

}

func TestPaymentFailureButPendingCheckPaymentPostgresFakeWallet(t *testing.T) {
Expand Down Expand Up @@ -299,6 +316,22 @@ func TestPaymentFailureButPendingCheckPaymentPostgresFakeWallet(t *testing.T) {
if proofs[0].State != cashu.PROOF_PENDING {
t.Errorf("Proof should be pending. it is now: %v", proofs[0].State)
}

req = httptest.NewRequest("POST", "/v1/melt/bolt11", strings.NewReader(string(jsonRequestBody)))
w = httptest.NewRecorder()
router.ServeHTTP(w, req)
var errorResponse cashu.ErrorResponse

err = json.Unmarshal(w.Body.Bytes(), &errorResponse)

if err != nil {
t.Fatalf("Could not parse error response %s", w.Body.String())
}

if errorResponse.Code != cashu.QUOTE_PENDING {
t.Errorf("Incorrect error code, got %v", errorResponse.Code)

}
}

func TestPaymentPendingButPendingCheckPaymentMockDbFakeWallet(t *testing.T) {
Expand Down

0 comments on commit f1685e4

Please sign in to comment.