Skip to content

Commit

Permalink
use require
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Oct 14, 2024
1 parent 715d729 commit 2105ca6
Showing 1 changed file with 11 additions and 31 deletions.
42 changes: 11 additions & 31 deletions precompiles/types/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ func Test_ErrInvalidAddr(t *testing.T) {
}
got := e.Error()
expect := "invalid address foo, reason: bar"
if got != expect {
t.Errorf("Expected %v, got %v", expect, got)
}
require.Equal(t, expect, got)
require.ErrorIs(t, ErrInvalidAddr{"foo", "bar"}, e)
}

Expand All @@ -26,9 +24,7 @@ func Test_ErrInvalidNumberOfArgs(t *testing.T) {
}
got := e.Error()
expect := "invalid number of arguments; expected 2; got: 1"
if got != expect {
t.Errorf("Expected %v, got %v", expect, got)
}
require.Equal(t, expect, got)
require.ErrorIs(t, ErrInvalidNumberOfArgs{1, 2}, e)
}

Expand All @@ -38,9 +34,7 @@ func Test_ErrInvalidArgument(t *testing.T) {
}
got := e.Error()
expect := "invalid argument: foo"
if got != expect {
t.Errorf("Expected %v, got %v", expect, got)
}
require.Equal(t, expect, got)
require.ErrorIs(t, ErrInvalidArgument{"foo"}, e)
}

Expand All @@ -50,9 +44,7 @@ func Test_ErrInvalidMethod(t *testing.T) {
}
got := e.Error()
expect := "invalid method: foo"
if got != expect {
t.Errorf("Expected %v, got %v", expect, got)
}
require.Equal(t, expect, got)
require.ErrorIs(t, ErrInvalidMethod{"foo"}, e)
}

Expand All @@ -65,9 +57,7 @@ func Test_ErrInvalidCoin(t *testing.T) {
}
got := e.Error()
expect := "invalid coin: denom: foo, is negative: true, is nil: false, is empty: false"
if got != expect {
t.Errorf("Expected %v, got %v", expect, got)
}
require.Equal(t, expect, got)
require.ErrorIs(t, ErrInvalidCoin{"foo", true, false, false}, e)
}

Expand All @@ -77,9 +67,7 @@ func Test_ErrInvalidAmount(t *testing.T) {
}
got := e.Error()
expect := "invalid token amount: foo"
if got != expect {
t.Errorf("Expected %v, got %v", expect, got)
}
require.Equal(t, expect, got)
require.ErrorIs(t, ErrInvalidAmount{"foo"}, e)
}

Expand All @@ -90,9 +78,7 @@ func Test_ErrUnexpected(t *testing.T) {
}
got := e.Error()
expect := "unexpected error in foo: bar"
if got != expect {
t.Errorf("Expected %v, got %v", expect, got)
}
require.Equal(t, expect, got)
require.ErrorIs(t, ErrUnexpected{"foo", "bar"}, e)
}

Expand All @@ -103,9 +89,7 @@ func Test_ErrInsufficientBalance(t *testing.T) {
}
got := e.Error()
expect := "insufficient balance: requested foo, current bar"
if got != expect {
t.Errorf("Expected %v, got %v", expect, got)
}
require.Equal(t, expect, got)
require.ErrorIs(t, ErrInsufficientBalance{"foo", "bar"}, e)
}

Expand All @@ -116,9 +100,7 @@ func Test_ErrInvalidToken(t *testing.T) {
}
got := e.Error()
expect := "invalid token foo: bar"
if got != expect {
t.Errorf("Expected %v, got %v", expect, got)
}
require.Equal(t, expect, got)
require.ErrorIs(t, ErrInvalidToken{"foo", "bar"}, e)
}

Expand All @@ -128,8 +110,6 @@ func Test_ErrWriteMethod(t *testing.T) {
}
got := e.Error()
expect := "method not allowed in read-only mode: foo"
if got != expect {
t.Errorf("Expected %v, got %v", expect, got)
}
require.Equal(t, expect, got)
require.ErrorIs(t, ErrWriteMethod{"foo"}, e)
}
}

0 comments on commit 2105ca6

Please sign in to comment.