Skip to content

Commit

Permalink
Prepare helper functions to be invoked from benchmark framework
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed Mar 4, 2024
1 parent 7113249 commit 54bb57a
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions tests/state_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"strings"
"testing"

"github.com/stretchr/testify/require"
"github.com/umbracle/fastrlp"

"github.com/0xPolygon/polygon-edge/chain"
Expand Down Expand Up @@ -57,7 +58,7 @@ type env struct {
Timestamp string `json:"currentTimestamp"`
}

func (e *env) ToHeader(t *testing.T) *types.Header {
func (e *env) ToHeader(t testing.TB) *types.Header {
t.Helper()

baseFee := uint64(0)
Expand All @@ -75,7 +76,7 @@ func (e *env) ToHeader(t *testing.T) *types.Header {
}
}

func (e *env) ToEnv(t *testing.T) runtime.TxContext {
func (e *env) ToEnv(t testing.TB) runtime.TxContext {
t.Helper()

baseFee := new(big.Int)
Expand Down Expand Up @@ -129,35 +130,29 @@ func stringToBigInt(str string) (*big.Int, error) {
return n, nil
}

func stringToBigIntT(t *testing.T, str string) *big.Int {
func stringToBigIntT(t testing.TB, str string) *big.Int {
t.Helper()

number, err := stringToBigInt(str)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)

return number
}

func stringToAddressT(t *testing.T, str string) types.Address {
func stringToAddressT(t testing.TB, str string) types.Address {
t.Helper()

address, err := stringToAddress(str)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)

return address
}

func stringToHashT(t *testing.T, str string) types.Hash {
func stringToHashT(t testing.TB, str string) types.Hash {
t.Helper()

address, err := stringToHash(str)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)

return address
}
Expand All @@ -171,24 +166,20 @@ func stringToUint64(str string) (uint64, error) {
return n.Uint64(), nil
}

func stringToUint64T(t *testing.T, str string) uint64 {
func stringToUint64T(t testing.TB, str string) uint64 {
t.Helper()

n, err := stringToUint64(str)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)

return n
}

func stringToInt64T(t *testing.T, str string) int64 {
func stringToInt64T(t testing.TB, str string) int64 {
t.Helper()

n, err := stringToUint64(str)
if err != nil {
t.Fatal(err)
}
require.NoError(t, err)

return int64(n)
}
Expand Down

0 comments on commit 54bb57a

Please sign in to comment.