laconicd-deprecated/types/validation_test.go
Federico Kunze 9cbb4dcf6d
stargate: migrate types (#670)
* changelog v0.4.0

* stargate: types changes

* msg and handler changes

* validation

* fixes

* more fixes

* more test fixes

* changelog

* changelog

* lint

* rm comment

* lint

* redundant if condition
2021-01-06 17:56:40 -03:00

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)
}
}