forked from cerc-io/laconicd-deprecated
crypto: updates from reviews (#535)
This commit is contained in:
@@ -5,16 +5,13 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/tharsis/ethermint/crypto/ethsecp256k1"
|
||||
"github.com/tharsis/ethermint/tests"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
)
|
||||
|
||||
func TestTransactionLogsValidate(t *testing.T) {
|
||||
priv, err := ethsecp256k1.GenerateKey()
|
||||
require.NoError(t, err)
|
||||
addr := crypto.PubkeyToAddress(priv.ToECDSA().PublicKey).String()
|
||||
addr := tests.GenerateAddress().String()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
@@ -90,9 +87,7 @@ func TestTransactionLogsValidate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestValidateLog(t *testing.T) {
|
||||
priv, err := ethsecp256k1.GenerateKey()
|
||||
require.NoError(t, err)
|
||||
addr := crypto.PubkeyToAddress(priv.ToECDSA().PublicKey).String()
|
||||
addr := tests.GenerateAddress().String()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
|
||||
@@ -8,12 +8,10 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/tharsis/ethermint/crypto/ethsecp256k1"
|
||||
"github.com/tharsis/ethermint/tests"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
)
|
||||
|
||||
const invalidFromAddress = "0x0000"
|
||||
@@ -32,15 +30,11 @@ func TestMsgsTestSuite(t *testing.T) {
|
||||
}
|
||||
|
||||
func (suite *MsgsTestSuite) SetupTest() {
|
||||
privFrom, err := ethsecp256k1.GenerateKey()
|
||||
suite.Require().NoError(err)
|
||||
|
||||
privTo, err := ethsecp256k1.GenerateKey()
|
||||
suite.Require().NoError(err)
|
||||
from, privFrom := tests.NewAddrKey()
|
||||
|
||||
suite.signer = tests.NewSigner(privFrom)
|
||||
suite.from = crypto.PubkeyToAddress(privFrom.ToECDSA().PublicKey)
|
||||
suite.to = crypto.PubkeyToAddress(privTo.ToECDSA().PublicKey)
|
||||
suite.from = from
|
||||
suite.to = tests.GenerateAddress()
|
||||
suite.chainID = big.NewInt(1)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,26 +10,14 @@ import (
|
||||
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
"github.com/tharsis/ethermint/app"
|
||||
"github.com/tharsis/ethermint/crypto/ethsecp256k1"
|
||||
"github.com/tharsis/ethermint/encoding"
|
||||
evmtypes "github.com/tharsis/ethermint/x/evm/types"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
)
|
||||
|
||||
// GenerateEthAddress generates an Ethereum address.
|
||||
func GenerateEthAddress() common.Address {
|
||||
priv, err := ethsecp256k1.GenerateKey()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return crypto.PubkeyToAddress(priv.ToECDSA().PublicKey)
|
||||
}
|
||||
|
||||
func TestEvmDataEncoding(t *testing.T) {
|
||||
ret := []byte{0x5, 0x8}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user