evm: update empty hash check for storage state (#1016)
This commit is contained in:
parent
70d52948da
commit
285c7c47d7
@ -2,11 +2,10 @@ package types
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
|
||||||
"github.com/tharsis/ethermint/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Storage represents the account Storage map as a slice of single key value
|
// Storage represents the account Storage map as a slice of single key value
|
||||||
@ -49,11 +48,12 @@ func (s Storage) Copy() Storage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate performs a basic validation of the State fields.
|
// Validate performs a basic validation of the State fields.
|
||||||
|
// NOTE: state value can be empty
|
||||||
func (s State) Validate() error {
|
func (s State) Validate() error {
|
||||||
if types.IsEmptyHash(s.Key) {
|
if strings.TrimSpace(s.Key) == "" {
|
||||||
return sdkerrors.Wrap(ErrInvalidState, "state key hash cannot be empty")
|
return sdkerrors.Wrap(ErrInvalidState, "state key hash cannot be blank")
|
||||||
}
|
}
|
||||||
// NOTE: state value can be empty
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ func TestStorageValidate(t *testing.T) {
|
|||||||
{
|
{
|
||||||
"empty storage key bytes",
|
"empty storage key bytes",
|
||||||
Storage{
|
Storage{
|
||||||
{Key: common.Hash{}.String()},
|
{Key: ""},
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user