forked from cerc-io/laconicd-deprecated
56 lines
952 B
Go
56 lines
952 B
Go
|
package types
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/require"
|
||
|
|
||
|
ethcmn "github.com/ethereum/go-ethereum/common"
|
||
|
)
|
||
|
|
||
|
func TestIsEmptyHash(t *testing.T) {
|
||
|
testCases := []struct {
|
||
|
name string
|
||
|
hash string
|
||
|
expEmpty bool
|
||
|
}{
|
||
|
{
|
||
|
"empty string", "", true,
|
||
|
},
|
||
|
{
|
||
|
"zero hash", ethcmn.Hash{}.String(), true,
|
||
|
},
|
||
|
|
||
|
{
|
||
|
"non-empty hash", ethcmn.BytesToHash([]byte{1, 2, 3, 4}).String(), false,
|
||
|
},
|
||
|
}
|
||
|
|
||
|
for _, tc := range testCases {
|
||
|
require.Equal(t, tc.expEmpty, IsEmptyHash(tc.hash), tc.name)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestIsZeroAddress(t *testing.T) {
|
||
|
testCases := []struct {
|
||
|
name string
|
||
|
address string
|
||
|
expEmpty bool
|
||
|
}{
|
||
|
{
|
||
|
"empty string", "", true,
|
||
|
},
|
||
|
{
|
||
|
"zero address", ethcmn.Address{}.String(), true,
|
||
|
},
|
||
|
|
||
|
{
|
||
|
"non-empty address", ethcmn.BytesToAddress([]byte{1, 2, 3, 4}).String(), false,
|
||
|
},
|
||
|
}
|
||
|
|
||
|
for _, tc := range testCases {
|
||
|
require.Equal(t, tc.expEmpty, IsZeroAddress(tc.address), tc.name)
|
||
|
}
|
||
|
}
|