From b7bec934f170c524819ada4baac846d18f498a5f Mon Sep 17 00:00:00 2001 From: skosito Date: Fri, 7 Jun 2024 17:21:51 +0200 Subject: [PATCH] revert importing suite.acc to keyring --- rpc/backend/backend_suite_test.go | 12 +++--------- rpc/backend/node_info_test.go | 21 +++++++++++++++++++-- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/rpc/backend/backend_suite_test.go b/rpc/backend/backend_suite_test.go index b1b362aa12..18a74edfd8 100644 --- a/rpc/backend/backend_suite_test.go +++ b/rpc/backend/backend_suite_test.go @@ -10,7 +10,6 @@ import ( dbm "github.com/cometbft/cometbft-db" tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/crypto" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/server" sdk "github.com/cosmos/cosmos-sdk/types" @@ -55,14 +54,9 @@ func (suite *BackendTestSuite) SetupTest() { panic(err) } - // Create Account with set sequence and import it in keyring - priv, err := ethsecp256k1.GenerateKey() - suite.Require().NoError(err) + // Create Account with set sequence - armor := crypto.EncryptArmorPrivKey(priv, "", "eth_secp256k1") - keyRing.ImportPrivKey("test_key", armor, "") - - suite.acc = sdk.AccAddress(priv.PubKey().Address().Bytes()) + suite.acc = sdk.AccAddress(tests.GenerateAddress().Bytes()) accounts := map[string]client.TestAccount{} accounts[suite.acc.String()] = client.TestAccount{ Address: suite.acc, @@ -70,7 +64,7 @@ func (suite *BackendTestSuite) SetupTest() { Seq: uint64(1), } - priv, err = ethsecp256k1.GenerateKey() + priv, err := ethsecp256k1.GenerateKey() suite.signer = tests.NewSigner(priv) suite.Require().NoError(err) diff --git a/rpc/backend/node_info_test.go b/rpc/backend/node_info_test.go index a25677e38b..12ef47607c 100644 --- a/rpc/backend/node_info_test.go +++ b/rpc/backend/node_info_test.go @@ -5,6 +5,8 @@ import ( "math/big" tmrpcclient "github.com/cometbft/cometbft/rpc/client" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/crypto" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" @@ -109,14 +111,14 @@ func (suite *BackendTestSuite) TestAccounts() { "pass - returns acc from keyring from ListAccounts", suite.backend.ListAccounts, func() {}, - []common.Address{common.Address(suite.acc)}, + []common.Address{}, true, }, { "pass - returns acc from keyring from Accounts", suite.backend.Accounts, func() {}, - []common.Address{common.Address(suite.acc)}, + []common.Address{}, true, }, } @@ -252,6 +254,21 @@ func (suite *BackendTestSuite) TestSetEtherbase() { { "pass - set the etherbase for the miner", func() { + priv, err := ethsecp256k1.GenerateKey() + suite.Require().NoError(err) + + armor := crypto.EncryptArmorPrivKey(priv, "", "eth_secp256k1") + suite.backend.clientCtx.Keyring.ImportPrivKey("test_key", armor, "") + + suite.acc = sdk.AccAddress(priv.PubKey().Address().Bytes()) + accounts := map[string]client.TestAccount{} + accounts[suite.acc.String()] = client.TestAccount{ + Address: suite.acc, + Num: uint64(1), + Seq: uint64(1), + } + + suite.backend.clientCtx = suite.backend.clientCtx.WithAccountRetriever(client.TestAccountRetriever{Accounts: accounts}) var header metadata.MD queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) RegisterParams(queryClient, &header, 1)