upgrade to ethermint v0.21.0 #99

Closed
0xmuralik wants to merge 384 commits from murali/update-fork into main
Showing only changes of commit 645e49bff5 - Show all commits

View File

@ -1,6 +1,7 @@
package hd package hd
import ( import (
"os"
"strings" "strings"
"testing" "testing"
@ -10,7 +11,6 @@ import (
hdwallet "github.com/miguelmota/go-ethereum-hdwallet" hdwallet "github.com/miguelmota/go-ethereum-hdwallet"
"github.com/cosmos/cosmos-sdk/codec"
amino "github.com/cosmos/cosmos-sdk/codec" amino "github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/crypto/keyring"
@ -20,10 +20,10 @@ import (
ethermint "github.com/evmos/ethermint/types" ethermint "github.com/evmos/ethermint/types"
) )
var TestCodec codec.Codec var TestCodec amino.Codec
func init() { func init() {
cdc := codec.NewLegacyAmino() cdc := amino.NewLegacyAmino()
cryptocodec.RegisterCrypto(cdc) cryptocodec.RegisterCrypto(cdc)
interfaceRegistry := types.NewInterfaceRegistry() interfaceRegistry := types.NewInterfaceRegistry()
@ -31,12 +31,18 @@ func init() {
enccodec.RegisterInterfaces(interfaceRegistry) enccodec.RegisterInterfaces(interfaceRegistry)
} }
const mnemonic = "picnic rent average infant boat squirrel federal assault mercy purity very motor fossil wheel verify upset box fresh horse vivid copy predict square regret" const (
mnemonic = "picnic rent average infant boat squirrel federal assault mercy purity very motor fossil wheel verify upset box fresh horse vivid copy predict square regret"
// hdWalletFixEnv defines whether the standard (correct) bip39
// derivation path was used, or if derivation was affected by
// https://github.com/btcsuite/btcutil/issues/172
hdWalletFixEnv = "GO_ETHEREUM_HDWALLET_FIX_ISSUE_179"
)
func TestKeyring(t *testing.T) { func TestKeyring(t *testing.T) {
dir := t.TempDir() dir := t.TempDir()
mockIn := strings.NewReader("") mockIn := strings.NewReader("")
kr, err := keyring.New("ethermint", keyring.BackendTest, dir, mockIn, TestCodec, EthSecp256k1Option()) kr, err := keyring.New("ethermint", keyring.BackendTest, dir, mockIn, TestCodec, EthSecp256k1Option())
require.NoError(t, err) require.NoError(t, err)
@ -68,7 +74,9 @@ func TestKeyring(t *testing.T) {
privkey := EthSecp256k1.Generate()(bz) privkey := EthSecp256k1.Generate()(bz)
addr := common.BytesToAddress(privkey.PubKey().Address().Bytes()) addr := common.BytesToAddress(privkey.PubKey().Address().Bytes())
os.Setenv(hdWalletFixEnv, "true")
wallet, err := hdwallet.NewFromMnemonic(mnemonic) wallet, err := hdwallet.NewFromMnemonic(mnemonic)
os.Setenv(hdWalletFixEnv, "")
require.NoError(t, err) require.NoError(t, err)
path := hdwallet.MustParseDerivationPath(hdPath) path := hdwallet.MustParseDerivationPath(hdPath)