Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxMustermann2 committed Sep 9, 2024
1 parent f080f54 commit 5acf528
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion types/account_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package types_test
package types

import (
"testing"
Expand Down
6 changes: 2 additions & 4 deletions types/benchmark_test.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package types_test
package types

import (
"fmt"
"testing"

"github.com/evmos/evmos/v14/types"
)

func BenchmarkParseChainID(b *testing.B) {
b.ReportAllocs()
// Start at 1, for valid EIP155, see regexEIP155 variable.
for i := 1; i < b.N; i++ {
chainID := fmt.Sprintf("evmos_1-%d", i)
if _, err := types.ParseChainID(chainID); err != nil {
if _, err := ParseChainID(chainID); err != nil {
b.Fatal(err)
}
}
Expand Down
9 changes: 4 additions & 5 deletions types/chain_id_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package types_test
package types

import (
"math/big"
"strings"
"testing"

"github.com/evmos/evmos/v14/types"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -73,16 +72,16 @@ func TestParseChainID(t *testing.T) {
}

for _, tc := range testCases {
chainIDEpoch, err := types.ParseChainID(tc.chainID)
chainIDEpoch, err := ParseChainID(tc.chainID)
if tc.expError {
require.Error(t, err, tc.name)
require.Nil(t, chainIDEpoch)

require.False(t, types.IsValidChainID(tc.chainID), tc.name)
require.False(t, IsValidChainID(tc.chainID), tc.name)
} else {
require.NoError(t, err, tc.name)
require.Equal(t, tc.expInt, chainIDEpoch, tc.name)
require.True(t, types.IsValidChainID(tc.chainID))
require.True(t, IsValidChainID(tc.chainID))
}
}
}
13 changes: 6 additions & 7 deletions types/validation_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package types_test
package types

import (
"testing"

utiltx "github.com/ExocoreNetwork/exocore/testutil/tx"
"github.com/ethereum/go-ethereum/common"
"github.com/evmos/evmos/v14/types"
"github.com/stretchr/testify/require"
)

Expand All @@ -28,7 +27,7 @@ func TestIsEmptyHash(t *testing.T) {
}

for _, tc := range testCases {
require.Equal(t, tc.expEmpty, types.IsEmptyHash(tc.hash), tc.name)
require.Equal(t, tc.expEmpty, IsEmptyHash(tc.hash), tc.name)
}
}

Expand All @@ -51,7 +50,7 @@ func TestIsZeroAddress(t *testing.T) {
}

for _, tc := range testCases {
require.Equal(t, tc.expEmpty, types.IsZeroAddress(tc.address), tc.name)
require.Equal(t, tc.expEmpty, IsZeroAddress(tc.address), tc.name)
}
}

Expand All @@ -76,7 +75,7 @@ func TestValidateAddress(t *testing.T) {
}

for _, tc := range testCases {
err := types.ValidateAddress(tc.address)
err := ValidateAddress(tc.address)

if tc.expError {
require.Error(t, err, tc.name)
Expand Down Expand Up @@ -107,7 +106,7 @@ func TestValidateNonZeroAddress(t *testing.T) {
}

for _, tc := range testCases {
err := types.ValidateNonZeroAddress(tc.address)
err := ValidateNonZeroAddress(tc.address)

if tc.expError {
require.Error(t, err, tc.name)
Expand All @@ -132,7 +131,7 @@ func TestSafeInt64(t *testing.T) {
}

for _, tc := range testCases {
value, err := types.SafeInt64(tc.value)
value, err := SafeInt64(tc.value)
if tc.expError {
require.Error(t, err, tc.name)
continue
Expand Down

0 comments on commit 5acf528

Please sign in to comment.