Skip to content

Commit

Permalink
revert importing suite.acc to keyring
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Jun 7, 2024
1 parent 4851c74 commit b7bec93
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
12 changes: 3 additions & 9 deletions rpc/backend/backend_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -55,22 +54,17 @@ 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,
Num: uint64(1),
Seq: uint64(1),
}

priv, err = ethsecp256k1.GenerateKey()
priv, err := ethsecp256k1.GenerateKey()
suite.signer = tests.NewSigner(priv)
suite.Require().NoError(err)

Expand Down
21 changes: 19 additions & 2 deletions rpc/backend/node_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
},
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b7bec93

Please sign in to comment.