forked from coinbase/x402
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors_test.go
More file actions
31 lines (26 loc) · 1.08 KB
/
errors_test.go
File metadata and controls
31 lines (26 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package x402
import "testing"
func TestVerifyErrorMessageFormatting(t *testing.T) {
withMessage := NewVerifyError("invalid_signature", "0xabc", "signature did not match")
expected := "invalid_signature: signature did not match"
if withMessage.Error() != expected {
t.Fatalf("expected %q, got %q", expected, withMessage.Error())
}
withoutMessage := NewVerifyError("missing_signature", "0xabc", "")
expected = "missing_signature"
if withoutMessage.Error() != expected {
t.Fatalf("expected %q, got %q", expected, withoutMessage.Error())
}
}
func TestSettleErrorMessageFormatting(t *testing.T) {
withMessage := NewSettleError("transaction_failed", "0xabc", "eip155:1", "0xtx", "execution reverted")
expected := "transaction_failed: execution reverted"
if withMessage.Error() != expected {
t.Fatalf("expected %q, got %q", expected, withMessage.Error())
}
withoutMessage := NewSettleError("insufficient_funds", "0xabc", "eip155:1", "0xtx", "")
expected = "insufficient_funds"
if withoutMessage.Error() != expected {
t.Fatalf("expected %q, got %q", expected, withoutMessage.Error())
}
}