From ad69909bbb73a87e0507331ec4fd2bba7b266d47 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Thu, 10 Nov 2022 16:25:10 +0800 Subject: [PATCH 1/4] enable fixIssue172 flag for test for more info, https://github.com/btcsuite/btcutil/pull/182/files --- crypto/hd/algorithm_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crypto/hd/algorithm_test.go b/crypto/hd/algorithm_test.go index 533c015a01..208cab4649 100644 --- a/crypto/hd/algorithm_test.go +++ b/crypto/hd/algorithm_test.go @@ -1,6 +1,7 @@ package hd import ( + "os" "strings" "testing" @@ -34,6 +35,7 @@ func init() { 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" func TestKeyring(t *testing.T) { + os.Setenv("GO_ETHEREUM_HDWALLET_FIX_ISSUE_179", "true") dir := t.TempDir() mockIn := strings.NewReader("") From bdfaaaf971cbfe312e43d41aac5210dbfe8d61d3 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Thu, 10 Nov 2022 18:02:43 +0800 Subject: [PATCH 2/4] fix import --- crypto/hd/algorithm_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crypto/hd/algorithm_test.go b/crypto/hd/algorithm_test.go index 208cab4649..d5e27a6d3b 100644 --- a/crypto/hd/algorithm_test.go +++ b/crypto/hd/algorithm_test.go @@ -11,7 +11,6 @@ import ( hdwallet "github.com/miguelmota/go-ethereum-hdwallet" - "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/crypto/keyring" @@ -21,10 +20,10 @@ import ( ethermint "github.com/evmos/ethermint/types" ) -var TestCodec codec.Codec +var TestCodec amino.Codec func init() { - cdc := codec.NewLegacyAmino() + cdc := amino.NewLegacyAmino() cryptocodec.RegisterCrypto(cdc) interfaceRegistry := types.NewInterfaceRegistry() From 253e1d9a9532de2209efce35eb6127f7b0c08934 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Thu, 10 Nov 2022 18:02:54 +0800 Subject: [PATCH 3/4] Apply suggestions from code review --- crypto/hd/algorithm_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crypto/hd/algorithm_test.go b/crypto/hd/algorithm_test.go index d5e27a6d3b..ed3026365e 100644 --- a/crypto/hd/algorithm_test.go +++ b/crypto/hd/algorithm_test.go @@ -34,7 +34,11 @@ func init() { 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" func TestKeyring(t *testing.T) { - os.Setenv("GO_ETHEREUM_HDWALLET_FIX_ISSUE_179", "true") + // hdWalletFixEnv defines whether the standard (correct) bip39 + // derivation path was used, or if derivation was affected by + // https://github.com/btcsuite/btcutil/issues/172 + const hdWalletFixEnv = "GO_ETHEREUM_HDWALLET_FIX_ISSUE_179" + os.Setenv(hdWalletFixEnv, "true") dir := t.TempDir() mockIn := strings.NewReader("") From 7349e9bde1de7b2a831d16192e2679385c312bd3 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Mon, 14 Nov 2022 22:13:47 +0800 Subject: [PATCH 4/4] Apply suggestions from code review --- crypto/hd/algorithm_test.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/crypto/hd/algorithm_test.go b/crypto/hd/algorithm_test.go index ed3026365e..144549f1f4 100644 --- a/crypto/hd/algorithm_test.go +++ b/crypto/hd/algorithm_test.go @@ -31,17 +31,18 @@ func init() { 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" -func TestKeyring(t *testing.T) { // hdWalletFixEnv defines whether the standard (correct) bip39 // derivation path was used, or if derivation was affected by // https://github.com/btcsuite/btcutil/issues/172 - const hdWalletFixEnv = "GO_ETHEREUM_HDWALLET_FIX_ISSUE_179" - os.Setenv(hdWalletFixEnv, "true") + hdWalletFixEnv = "GO_ETHEREUM_HDWALLET_FIX_ISSUE_179" +) + +func TestKeyring(t *testing.T) { dir := t.TempDir() mockIn := strings.NewReader("") - kr, err := keyring.New("ethermint", keyring.BackendTest, dir, mockIn, TestCodec, EthSecp256k1Option()) require.NoError(t, err) @@ -73,7 +74,9 @@ func TestKeyring(t *testing.T) { privkey := EthSecp256k1.Generate()(bz) addr := common.BytesToAddress(privkey.PubKey().Address().Bytes()) + os.Setenv(hdWalletFixEnv, "true") wallet, err := hdwallet.NewFromMnemonic(mnemonic) + os.Setenv(hdWalletFixEnv, "") require.NoError(t, err) path := hdwallet.MustParseDerivationPath(hdPath)