Sync from fork #74
375
rpc/backend/account_info_test.go
Normal file
375
rpc/backend/account_info_test.go
Normal file
@ -0,0 +1,375 @@
|
|||||||
|
package backend
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"math/big"
|
||||||
|
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
|
tmrpcclient "github.com/tendermint/tendermint/rpc/client"
|
||||||
|
|
||||||
|
"github.com/evmos/ethermint/rpc/backend/mocks"
|
||||||
|
rpctypes "github.com/evmos/ethermint/rpc/types"
|
||||||
|
"github.com/evmos/ethermint/tests"
|
||||||
|
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (suite *BackendTestSuite) TestGetCode() {
|
||||||
|
blockNr := rpctypes.NewBlockNumber(big.NewInt(1))
|
||||||
|
contractCode := []byte("0xef616c92f3cfc9e92dc270d6acff9cea213cecc7020a76ee4395af09bdceb4837a1ebdb5735e11e7d3adb6104e0c3ac55180b4ddf5e54d022cc5e8837f6a4f971b")
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
name string
|
||||||
|
addr common.Address
|
||||||
|
blockNrOrHash rpctypes.BlockNumberOrHash
|
||||||
|
registerMock func(common.Address)
|
||||||
|
expPass bool
|
||||||
|
expCode hexutil.Bytes
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"fail - BlockHash and BlockNumber are both nil ",
|
||||||
|
tests.GenerateAddress(),
|
||||||
|
rpctypes.BlockNumberOrHash{},
|
||||||
|
func(addr common.Address) {},
|
||||||
|
false,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fail - query client errors on getting Code",
|
||||||
|
tests.GenerateAddress(),
|
||||||
|
rpctypes.BlockNumberOrHash{BlockNumber: &blockNr},
|
||||||
|
func(addr common.Address) {
|
||||||
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
|
RegisterCodeError(queryClient, addr)
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pass",
|
||||||
|
tests.GenerateAddress(),
|
||||||
|
rpctypes.BlockNumberOrHash{BlockNumber: &blockNr},
|
||||||
|
func(addr common.Address) {
|
||||||
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
|
RegisterCode(queryClient, addr, contractCode)
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
contractCode,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tc := range testCases {
|
||||||
|
suite.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||||
|
suite.SetupTest() // reset
|
||||||
|
tc.registerMock(tc.addr)
|
||||||
|
|
||||||
|
code, err := suite.backend.GetCode(tc.addr, tc.blockNrOrHash)
|
||||||
|
if tc.expPass {
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.Require().Equal(tc.expCode, code)
|
||||||
|
} else {
|
||||||
|
suite.Require().Error(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *BackendTestSuite) TestGetProof() {
|
||||||
|
blockNrInvalid := rpctypes.NewBlockNumber(big.NewInt(1))
|
||||||
|
blockNr := rpctypes.NewBlockNumber(big.NewInt(4))
|
||||||
|
address1 := tests.GenerateAddress()
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
name string
|
||||||
|
addr common.Address
|
||||||
|
storageKeys []string
|
||||||
|
blockNrOrHash rpctypes.BlockNumberOrHash
|
||||||
|
registerMock func(rpctypes.BlockNumber, common.Address)
|
||||||
|
expPass bool
|
||||||
|
expAccRes *rpctypes.AccountResult
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"fail - BlockNumeber = 1 (invalidBlockNumber)",
|
||||||
|
address1,
|
||||||
|
[]string{},
|
||||||
|
rpctypes.BlockNumberOrHash{BlockNumber: &blockNrInvalid},
|
||||||
|
func(bn rpctypes.BlockNumber, addr common.Address) {
|
||||||
|
client := suite.backend.clientCtx.Client.(*mocks.Client)
|
||||||
|
RegisterBlock(client, bn.Int64(), nil)
|
||||||
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
|
RegisterAccount(queryClient, addr, blockNrInvalid.Int64())
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
&rpctypes.AccountResult{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pass",
|
||||||
|
address1,
|
||||||
|
[]string{"0x0"},
|
||||||
|
rpctypes.BlockNumberOrHash{BlockNumber: &blockNr},
|
||||||
|
func(bn rpctypes.BlockNumber, addr common.Address) {
|
||||||
|
suite.backend.ctx = rpctypes.ContextWithHeight(bn.Int64())
|
||||||
|
|
||||||
|
client := suite.backend.clientCtx.Client.(*mocks.Client)
|
||||||
|
RegisterBlock(client, bn.Int64(), nil)
|
||||||
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
|
RegisterAccount(queryClient, addr, bn.Int64())
|
||||||
|
|
||||||
|
// Use the IAVL height if a valid tendermint height is passed in.
|
||||||
|
ivalHeight := bn.Int64() - 1
|
||||||
|
RegisterABCIQueryWithOptions(
|
||||||
|
client,
|
||||||
|
bn.Int64(),
|
||||||
|
"store/evm/key",
|
||||||
|
evmtypes.StateKey(address1, common.HexToHash("0x0").Bytes()),
|
||||||
|
tmrpcclient.ABCIQueryOptions{Height: ivalHeight, Prove: true},
|
||||||
|
)
|
||||||
|
RegisterABCIQueryWithOptions(
|
||||||
|
client,
|
||||||
|
bn.Int64(),
|
||||||
|
"store/acc/key",
|
||||||
|
authtypes.AddressStoreKey(sdk.AccAddress(address1.Bytes())),
|
||||||
|
tmrpcclient.ABCIQueryOptions{Height: ivalHeight, Prove: true},
|
||||||
|
)
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
&rpctypes.AccountResult{
|
||||||
|
Address: address1,
|
||||||
|
AccountProof: []string{""},
|
||||||
|
Balance: (*hexutil.Big)(big.NewInt(0)),
|
||||||
|
CodeHash: common.HexToHash(""),
|
||||||
|
Nonce: 0x0,
|
||||||
|
StorageHash: common.Hash{},
|
||||||
|
StorageProof: []rpctypes.StorageResult{
|
||||||
|
{
|
||||||
|
Key: "0x0",
|
||||||
|
Value: (*hexutil.Big)(big.NewInt(2)),
|
||||||
|
Proof: []string{""},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tc := range testCases {
|
||||||
|
suite.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||||
|
suite.SetupTest()
|
||||||
|
tc.registerMock(*tc.blockNrOrHash.BlockNumber, tc.addr)
|
||||||
|
|
||||||
|
accRes, err := suite.backend.GetProof(tc.addr, tc.storageKeys, tc.blockNrOrHash)
|
||||||
|
|
||||||
|
if tc.expPass {
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.Require().Equal(tc.expAccRes, accRes)
|
||||||
|
} else {
|
||||||
|
suite.Require().Error(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *BackendTestSuite) TestGetStorageAt() {
|
||||||
|
blockNr := rpctypes.NewBlockNumber(big.NewInt(1))
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
name string
|
||||||
|
addr common.Address
|
||||||
|
key string
|
||||||
|
blockNrOrHash rpctypes.BlockNumberOrHash
|
||||||
|
registerMock func(common.Address, string, string)
|
||||||
|
expPass bool
|
||||||
|
expStorage hexutil.Bytes
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"fail - BlockHash and BlockNumber are both nil",
|
||||||
|
tests.GenerateAddress(),
|
||||||
|
"0x0",
|
||||||
|
rpctypes.BlockNumberOrHash{},
|
||||||
|
func(addr common.Address, key string, storage string) {},
|
||||||
|
false,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fail - query client errors on getting Storage",
|
||||||
|
tests.GenerateAddress(),
|
||||||
|
"0x0",
|
||||||
|
rpctypes.BlockNumberOrHash{BlockNumber: &blockNr},
|
||||||
|
func(addr common.Address, key string, storage string) {
|
||||||
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
|
RegisterStorageAtError(queryClient, addr, key)
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pass",
|
||||||
|
tests.GenerateAddress(),
|
||||||
|
"0x0",
|
||||||
|
rpctypes.BlockNumberOrHash{BlockNumber: &blockNr},
|
||||||
|
func(addr common.Address, key string, storage string) {
|
||||||
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
|
RegisterStorageAt(queryClient, addr, key, storage)
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
hexutil.Bytes{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tc := range testCases {
|
||||||
|
suite.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||||
|
suite.SetupTest()
|
||||||
|
tc.registerMock(tc.addr, tc.key, tc.expStorage.String())
|
||||||
|
|
||||||
|
storage, err := suite.backend.GetStorageAt(tc.addr, tc.key, tc.blockNrOrHash)
|
||||||
|
if tc.expPass {
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.Require().Equal(tc.expStorage, storage)
|
||||||
|
} else {
|
||||||
|
suite.Require().Error(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *BackendTestSuite) TestGetBalance() {
|
||||||
|
blockNr := rpctypes.NewBlockNumber(big.NewInt(1))
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
name string
|
||||||
|
addr common.Address
|
||||||
|
blockNrOrHash rpctypes.BlockNumberOrHash
|
||||||
|
registerMock func(rpctypes.BlockNumber, common.Address)
|
||||||
|
expPass bool
|
||||||
|
expBalance *hexutil.Big
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"fail - BlockHash and BlockNumber are both nil",
|
||||||
|
tests.GenerateAddress(),
|
||||||
|
rpctypes.BlockNumberOrHash{},
|
||||||
|
func(bn rpctypes.BlockNumber, addr common.Address) {
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fail - tendermint client failed to get block",
|
||||||
|
tests.GenerateAddress(),
|
||||||
|
rpctypes.BlockNumberOrHash{BlockNumber: &blockNr},
|
||||||
|
func(bn rpctypes.BlockNumber, addr common.Address) {
|
||||||
|
client := suite.backend.clientCtx.Client.(*mocks.Client)
|
||||||
|
RegisterBlockError(client, bn.Int64())
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fail - query client failed to get balance",
|
||||||
|
tests.GenerateAddress(),
|
||||||
|
rpctypes.BlockNumberOrHash{BlockNumber: &blockNr},
|
||||||
|
func(bn rpctypes.BlockNumber, addr common.Address) {
|
||||||
|
client := suite.backend.clientCtx.Client.(*mocks.Client)
|
||||||
|
RegisterBlock(client, bn.Int64(), nil)
|
||||||
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
|
RegisterBalanceError(queryClient, addr, bn.Int64())
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fail - invalid balance",
|
||||||
|
tests.GenerateAddress(),
|
||||||
|
rpctypes.BlockNumberOrHash{BlockNumber: &blockNr},
|
||||||
|
func(bn rpctypes.BlockNumber, addr common.Address) {
|
||||||
|
client := suite.backend.clientCtx.Client.(*mocks.Client)
|
||||||
|
RegisterBlock(client, bn.Int64(), nil)
|
||||||
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
|
RegisterBalanceInvalid(queryClient, addr, bn.Int64())
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fail - pruned node state",
|
||||||
|
tests.GenerateAddress(),
|
||||||
|
rpctypes.BlockNumberOrHash{BlockNumber: &blockNr},
|
||||||
|
func(bn rpctypes.BlockNumber, addr common.Address) {
|
||||||
|
client := suite.backend.clientCtx.Client.(*mocks.Client)
|
||||||
|
RegisterBlock(client, bn.Int64(), nil)
|
||||||
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
|
RegisterBalanceNegative(queryClient, addr, bn.Int64())
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
nil,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pass",
|
||||||
|
tests.GenerateAddress(),
|
||||||
|
rpctypes.BlockNumberOrHash{BlockNumber: &blockNr},
|
||||||
|
func(bn rpctypes.BlockNumber, addr common.Address) {
|
||||||
|
client := suite.backend.clientCtx.Client.(*mocks.Client)
|
||||||
|
RegisterBlock(client, bn.Int64(), nil)
|
||||||
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
|
RegisterBalance(queryClient, addr, bn.Int64())
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
(*hexutil.Big)(big.NewInt(1)),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tc := range testCases {
|
||||||
|
suite.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||||
|
suite.SetupTest()
|
||||||
|
|
||||||
|
// avoid nil pointer reference
|
||||||
|
if tc.blockNrOrHash.BlockNumber != nil {
|
||||||
|
tc.registerMock(*tc.blockNrOrHash.BlockNumber, tc.addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
balance, err := suite.backend.GetBalance(tc.addr, tc.blockNrOrHash)
|
||||||
|
if tc.expPass {
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.Require().Equal(tc.expBalance, balance)
|
||||||
|
} else {
|
||||||
|
suite.Require().Error(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *BackendTestSuite) TestGetTransactionCount() {
|
||||||
|
testCases := []struct {
|
||||||
|
name string
|
||||||
|
accExists bool
|
||||||
|
blockNum rpctypes.BlockNumber
|
||||||
|
registerMock func(common.Address, rpctypes.BlockNumber)
|
||||||
|
expPass bool
|
||||||
|
expTxCount hexutil.Uint64
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"pass - account doesn't exist",
|
||||||
|
false,
|
||||||
|
rpctypes.NewBlockNumber(big.NewInt(1)),
|
||||||
|
func(addr common.Address, bn rpctypes.BlockNumber) {},
|
||||||
|
true,
|
||||||
|
hexutil.Uint64(0),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tc := range testCases {
|
||||||
|
suite.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||||
|
suite.SetupTest()
|
||||||
|
|
||||||
|
addr := tests.GenerateAddress()
|
||||||
|
if tc.accExists {
|
||||||
|
addr = common.BytesToAddress(suite.acc.Bytes())
|
||||||
|
}
|
||||||
|
|
||||||
|
tc.registerMock(addr, tc.blockNum)
|
||||||
|
|
||||||
|
txCount, err := suite.backend.GetTransactionCount(addr, tc.blockNum)
|
||||||
|
if tc.expPass {
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.Require().Equal(tc.expTxCount, *txCount)
|
||||||
|
} else {
|
||||||
|
suite.Require().Error(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
@ -25,12 +25,14 @@ import (
|
|||||||
"github.com/evmos/ethermint/indexer"
|
"github.com/evmos/ethermint/indexer"
|
||||||
"github.com/evmos/ethermint/rpc/backend/mocks"
|
"github.com/evmos/ethermint/rpc/backend/mocks"
|
||||||
rpctypes "github.com/evmos/ethermint/rpc/types"
|
rpctypes "github.com/evmos/ethermint/rpc/types"
|
||||||
|
"github.com/evmos/ethermint/tests"
|
||||||
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BackendTestSuite struct {
|
type BackendTestSuite struct {
|
||||||
suite.Suite
|
suite.Suite
|
||||||
backend *Backend
|
backend *Backend
|
||||||
|
acc sdk.AccAddress
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBackendTestSuite(t *testing.T) {
|
func TestBackendTestSuite(t *testing.T) {
|
||||||
@ -50,19 +52,29 @@ func (suite *BackendTestSuite) SetupTest() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create Account with set sequence
|
||||||
|
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),
|
||||||
|
}
|
||||||
|
|
||||||
encodingConfig := encoding.MakeConfig(app.ModuleBasics)
|
encodingConfig := encoding.MakeConfig(app.ModuleBasics)
|
||||||
clientCtx := client.Context{}.WithChainID("ethermint_9000-1").
|
clientCtx := client.Context{}.WithChainID("ethermint_9000-1").
|
||||||
WithHeight(1).
|
WithHeight(1).
|
||||||
WithTxConfig(encodingConfig.TxConfig).
|
WithTxConfig(encodingConfig.TxConfig).
|
||||||
WithKeyringDir(clientDir).
|
WithKeyringDir(clientDir).
|
||||||
WithKeyring(keyRing)
|
WithKeyring(keyRing).
|
||||||
|
WithAccountRetriever(client.TestAccountRetriever{Accounts: accounts})
|
||||||
|
|
||||||
allowUnprotectedTxs := false
|
allowUnprotectedTxs := false
|
||||||
|
|
||||||
idxer := indexer.NewKVIndexer(dbm.NewMemDB(), ctx.Logger, clientCtx)
|
idxer := indexer.NewKVIndexer(dbm.NewMemDB(), ctx.Logger, clientCtx)
|
||||||
|
|
||||||
suite.backend = NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, idxer)
|
suite.backend = NewBackend(ctx, ctx.Logger, clientCtx, allowUnprotectedTxs, idxer)
|
||||||
suite.backend.queryClient.QueryClient = mocks.NewQueryClient(suite.T())
|
suite.backend.queryClient.QueryClient = mocks.NewEVMQueryClient(suite.T())
|
||||||
suite.backend.clientCtx.Client = mocks.NewClient(suite.T())
|
suite.backend.clientCtx.Client = mocks.NewClient(suite.T())
|
||||||
suite.backend.ctx = rpctypes.ContextWithHeight(1)
|
suite.backend.ctx = rpctypes.ContextWithHeight(1)
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ func (suite *BackendTestSuite) TestBlockNumber() {
|
|||||||
func() {
|
func() {
|
||||||
height := int64(1)
|
height := int64(1)
|
||||||
var header metadata.MD
|
var header metadata.MD
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterParamsInvalidHeight(queryClient, &header, int64(height))
|
RegisterParamsInvalidHeight(queryClient, &header, int64(height))
|
||||||
},
|
},
|
||||||
0x0,
|
0x0,
|
||||||
@ -43,7 +43,7 @@ func (suite *BackendTestSuite) TestBlockNumber() {
|
|||||||
func() {
|
func() {
|
||||||
height := int64(1)
|
height := int64(1)
|
||||||
var header metadata.MD
|
var header metadata.MD
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterParamsInvalidHeader(queryClient, &header, int64(height))
|
RegisterParamsInvalidHeader(queryClient, &header, int64(height))
|
||||||
},
|
},
|
||||||
0x0,
|
0x0,
|
||||||
@ -54,7 +54,7 @@ func (suite *BackendTestSuite) TestBlockNumber() {
|
|||||||
func() {
|
func() {
|
||||||
height := int64(1)
|
height := int64(1)
|
||||||
var header metadata.MD
|
var header metadata.MD
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterParams(queryClient, &header, int64(height))
|
RegisterParams(queryClient, &header, int64(height))
|
||||||
},
|
},
|
||||||
0x1,
|
0x1,
|
||||||
@ -161,7 +161,7 @@ func (suite *BackendTestSuite) TestGetBlockByNumber() {
|
|||||||
blockRes, _ = RegisterBlockResults(client, blockNum.Int64())
|
blockRes, _ = RegisterBlockResults(client, blockNum.Int64())
|
||||||
RegisterConsensusParams(client, height)
|
RegisterConsensusParams(client, height)
|
||||||
|
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFee(queryClient, baseFee)
|
RegisterBaseFee(queryClient, baseFee)
|
||||||
RegisterValidatorAccount(queryClient, validator)
|
RegisterValidatorAccount(queryClient, validator)
|
||||||
},
|
},
|
||||||
@ -183,7 +183,7 @@ func (suite *BackendTestSuite) TestGetBlockByNumber() {
|
|||||||
blockRes, _ = RegisterBlockResults(client, blockNum.Int64())
|
blockRes, _ = RegisterBlockResults(client, blockNum.Int64())
|
||||||
RegisterConsensusParams(client, height)
|
RegisterConsensusParams(client, height)
|
||||||
|
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFee(queryClient, baseFee)
|
RegisterBaseFee(queryClient, baseFee)
|
||||||
RegisterValidatorAccount(queryClient, validator)
|
RegisterValidatorAccount(queryClient, validator)
|
||||||
},
|
},
|
||||||
@ -306,7 +306,7 @@ func (suite *BackendTestSuite) TestGetBlockByHash() {
|
|||||||
blockRes, _ = RegisterBlockResults(client, height)
|
blockRes, _ = RegisterBlockResults(client, height)
|
||||||
RegisterConsensusParams(client, height)
|
RegisterConsensusParams(client, height)
|
||||||
|
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFee(queryClient, baseFee)
|
RegisterBaseFee(queryClient, baseFee)
|
||||||
RegisterValidatorAccount(queryClient, validator)
|
RegisterValidatorAccount(queryClient, validator)
|
||||||
},
|
},
|
||||||
@ -329,7 +329,7 @@ func (suite *BackendTestSuite) TestGetBlockByHash() {
|
|||||||
blockRes, _ = RegisterBlockResults(client, height)
|
blockRes, _ = RegisterBlockResults(client, height)
|
||||||
RegisterConsensusParams(client, height)
|
RegisterConsensusParams(client, height)
|
||||||
|
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFee(queryClient, baseFee)
|
RegisterBaseFee(queryClient, baseFee)
|
||||||
RegisterValidatorAccount(queryClient, validator)
|
RegisterValidatorAccount(queryClient, validator)
|
||||||
},
|
},
|
||||||
@ -554,7 +554,7 @@ func (suite *BackendTestSuite) TestTendermintBlockByNumber() {
|
|||||||
func(_ ethrpc.BlockNumber) {
|
func(_ ethrpc.BlockNumber) {
|
||||||
appHeight := int64(1)
|
appHeight := int64(1)
|
||||||
var header metadata.MD
|
var header metadata.MD
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterParamsError(queryClient, &header, appHeight)
|
RegisterParamsError(queryClient, &header, appHeight)
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
@ -566,7 +566,7 @@ func (suite *BackendTestSuite) TestTendermintBlockByNumber() {
|
|||||||
func(blockNum ethrpc.BlockNumber) {
|
func(blockNum ethrpc.BlockNumber) {
|
||||||
appHeight := int64(1)
|
appHeight := int64(1)
|
||||||
var header metadata.MD
|
var header metadata.MD
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterParams(queryClient, &header, appHeight)
|
RegisterParams(queryClient, &header, appHeight)
|
||||||
|
|
||||||
tmHeight := appHeight
|
tmHeight := appHeight
|
||||||
@ -901,7 +901,7 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() {
|
|||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
func(baseFee sdk.Int, validator sdk.AccAddress, height int64) {
|
func(baseFee sdk.Int, validator sdk.AccAddress, height int64) {
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFee(queryClient, baseFee)
|
RegisterBaseFee(queryClient, baseFee)
|
||||||
RegisterValidatorAccount(queryClient, validator)
|
RegisterValidatorAccount(queryClient, validator)
|
||||||
|
|
||||||
@ -925,7 +925,7 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() {
|
|||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
func(baseFee sdk.Int, validator sdk.AccAddress, height int64) {
|
func(baseFee sdk.Int, validator sdk.AccAddress, height int64) {
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFeeError(queryClient)
|
RegisterBaseFeeError(queryClient)
|
||||||
RegisterValidatorAccount(queryClient, validator)
|
RegisterValidatorAccount(queryClient, validator)
|
||||||
|
|
||||||
@ -949,7 +949,7 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() {
|
|||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
func(baseFee sdk.Int, validator sdk.AccAddress, height int64) {
|
func(baseFee sdk.Int, validator sdk.AccAddress, height int64) {
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFee(queryClient, baseFee)
|
RegisterBaseFee(queryClient, baseFee)
|
||||||
RegisterValidatorAccountError(queryClient)
|
RegisterValidatorAccountError(queryClient)
|
||||||
|
|
||||||
@ -973,7 +973,7 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() {
|
|||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
func(baseFee sdk.Int, validator sdk.AccAddress, height int64) {
|
func(baseFee sdk.Int, validator sdk.AccAddress, height int64) {
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFee(queryClient, baseFee)
|
RegisterBaseFee(queryClient, baseFee)
|
||||||
RegisterValidatorAccount(queryClient, validator)
|
RegisterValidatorAccount(queryClient, validator)
|
||||||
|
|
||||||
@ -1003,7 +1003,7 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() {
|
|||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
func(baseFee sdk.Int, validator sdk.AccAddress, height int64) {
|
func(baseFee sdk.Int, validator sdk.AccAddress, height int64) {
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFee(queryClient, baseFee)
|
RegisterBaseFee(queryClient, baseFee)
|
||||||
RegisterValidatorAccount(queryClient, validator)
|
RegisterValidatorAccount(queryClient, validator)
|
||||||
|
|
||||||
@ -1027,7 +1027,7 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() {
|
|||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
func(baseFee sdk.Int, validator sdk.AccAddress, height int64) {
|
func(baseFee sdk.Int, validator sdk.AccAddress, height int64) {
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFee(queryClient, baseFee)
|
RegisterBaseFee(queryClient, baseFee)
|
||||||
RegisterValidatorAccount(queryClient, validator)
|
RegisterValidatorAccount(queryClient, validator)
|
||||||
|
|
||||||
@ -1051,7 +1051,7 @@ func (suite *BackendTestSuite) TestGetEthBlockFromTendermint() {
|
|||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
func(baseFee sdk.Int, validator sdk.AccAddress, height int64) {
|
func(baseFee sdk.Int, validator sdk.AccAddress, height int64) {
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFee(queryClient, baseFee)
|
RegisterBaseFee(queryClient, baseFee)
|
||||||
RegisterValidatorAccount(queryClient, validator)
|
RegisterValidatorAccount(queryClient, validator)
|
||||||
|
|
||||||
@ -1237,7 +1237,7 @@ func (suite *BackendTestSuite) TestHeaderByNumber() {
|
|||||||
expResultBlock, _ = RegisterBlock(client, height, nil)
|
expResultBlock, _ = RegisterBlock(client, height, nil)
|
||||||
RegisterBlockResults(client, height)
|
RegisterBlockResults(client, height)
|
||||||
|
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFeeError(queryClient)
|
RegisterBaseFeeError(queryClient)
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
@ -1252,7 +1252,7 @@ func (suite *BackendTestSuite) TestHeaderByNumber() {
|
|||||||
expResultBlock, _ = RegisterBlock(client, height, nil)
|
expResultBlock, _ = RegisterBlock(client, height, nil)
|
||||||
RegisterBlockResults(client, height)
|
RegisterBlockResults(client, height)
|
||||||
|
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFee(queryClient, baseFee)
|
RegisterBaseFee(queryClient, baseFee)
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
@ -1267,7 +1267,7 @@ func (suite *BackendTestSuite) TestHeaderByNumber() {
|
|||||||
expResultBlock, _ = RegisterBlock(client, height, bz)
|
expResultBlock, _ = RegisterBlock(client, height, bz)
|
||||||
RegisterBlockResults(client, height)
|
RegisterBlockResults(client, height)
|
||||||
|
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFee(queryClient, baseFee)
|
RegisterBaseFee(queryClient, baseFee)
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
@ -1347,7 +1347,7 @@ func (suite *BackendTestSuite) TestHeaderByHash() {
|
|||||||
expResultBlock, _ = RegisterBlockByHash(client, hash, bz)
|
expResultBlock, _ = RegisterBlockByHash(client, hash, bz)
|
||||||
RegisterBlockResults(client, height)
|
RegisterBlockResults(client, height)
|
||||||
|
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFeeError(queryClient)
|
RegisterBaseFeeError(queryClient)
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
@ -1362,7 +1362,7 @@ func (suite *BackendTestSuite) TestHeaderByHash() {
|
|||||||
expResultBlock, _ = RegisterBlockByHash(client, hash, nil)
|
expResultBlock, _ = RegisterBlockByHash(client, hash, nil)
|
||||||
RegisterBlockResults(client, height)
|
RegisterBlockResults(client, height)
|
||||||
|
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFee(queryClient, baseFee)
|
RegisterBaseFee(queryClient, baseFee)
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
@ -1377,7 +1377,7 @@ func (suite *BackendTestSuite) TestHeaderByHash() {
|
|||||||
expResultBlock, _ = RegisterBlockByHash(client, hash, bz)
|
expResultBlock, _ = RegisterBlockByHash(client, hash, bz)
|
||||||
RegisterBlockResults(client, height)
|
RegisterBlockResults(client, height)
|
||||||
|
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFee(queryClient, baseFee)
|
RegisterBaseFee(queryClient, baseFee)
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
@ -1444,7 +1444,7 @@ func (suite *BackendTestSuite) TestEthBlockByNumber() {
|
|||||||
RegisterBlock(client, height, nil)
|
RegisterBlock(client, height, nil)
|
||||||
|
|
||||||
RegisterBlockResults(client, blockNum.Int64())
|
RegisterBlockResults(client, blockNum.Int64())
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
baseFee := sdk.NewInt(1)
|
baseFee := sdk.NewInt(1)
|
||||||
RegisterBaseFee(queryClient, baseFee)
|
RegisterBaseFee(queryClient, baseFee)
|
||||||
},
|
},
|
||||||
@ -1470,7 +1470,7 @@ func (suite *BackendTestSuite) TestEthBlockByNumber() {
|
|||||||
RegisterBlock(client, height, bz)
|
RegisterBlock(client, height, bz)
|
||||||
|
|
||||||
RegisterBlockResults(client, blockNum.Int64())
|
RegisterBlockResults(client, blockNum.Int64())
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
baseFee := sdk.NewInt(1)
|
baseFee := sdk.NewInt(1)
|
||||||
RegisterBaseFee(queryClient, baseFee)
|
RegisterBaseFee(queryClient, baseFee)
|
||||||
},
|
},
|
||||||
@ -1535,7 +1535,7 @@ func (suite *BackendTestSuite) TestEthBlockFromTendermintBlock() {
|
|||||||
TxsResults: []*types.ResponseDeliverTx{{Code: 0, GasUsed: 0}},
|
TxsResults: []*types.ResponseDeliverTx{{Code: 0, GasUsed: 0}},
|
||||||
},
|
},
|
||||||
func(baseFee sdk.Int, blockNum int64) {
|
func(baseFee sdk.Int, blockNum int64) {
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFee(queryClient, baseFee)
|
RegisterBaseFee(queryClient, baseFee)
|
||||||
},
|
},
|
||||||
ethtypes.NewBlock(
|
ethtypes.NewBlock(
|
||||||
@ -1570,7 +1570,7 @@ func (suite *BackendTestSuite) TestEthBlockFromTendermintBlock() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
func(baseFee sdk.Int, blockNum int64) {
|
func(baseFee sdk.Int, blockNum int64) {
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFee(queryClient, baseFee)
|
RegisterBaseFee(queryClient, baseFee)
|
||||||
},
|
},
|
||||||
ethtypes.NewBlock(
|
ethtypes.NewBlock(
|
||||||
|
@ -27,7 +27,7 @@ func (suite *BackendTestSuite) TestBaseFee() {
|
|||||||
"fail - grpc BaseFee error",
|
"fail - grpc BaseFee error",
|
||||||
&tmrpctypes.ResultBlockResults{Height: 1},
|
&tmrpctypes.ResultBlockResults{Height: 1},
|
||||||
func() {
|
func() {
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFeeError(queryClient)
|
RegisterBaseFeeError(queryClient)
|
||||||
},
|
},
|
||||||
nil,
|
nil,
|
||||||
@ -44,7 +44,7 @@ func (suite *BackendTestSuite) TestBaseFee() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
func() {
|
func() {
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFeeError(queryClient)
|
RegisterBaseFeeError(queryClient)
|
||||||
},
|
},
|
||||||
nil,
|
nil,
|
||||||
@ -61,7 +61,7 @@ func (suite *BackendTestSuite) TestBaseFee() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
func() {
|
func() {
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFeeError(queryClient)
|
RegisterBaseFeeError(queryClient)
|
||||||
},
|
},
|
||||||
nil,
|
nil,
|
||||||
@ -81,7 +81,7 @@ func (suite *BackendTestSuite) TestBaseFee() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
func() {
|
func() {
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFeeError(queryClient)
|
RegisterBaseFeeError(queryClient)
|
||||||
},
|
},
|
||||||
nil,
|
nil,
|
||||||
@ -101,7 +101,7 @@ func (suite *BackendTestSuite) TestBaseFee() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
func() {
|
func() {
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFeeError(queryClient)
|
RegisterBaseFeeError(queryClient)
|
||||||
},
|
},
|
||||||
baseFee.BigInt(),
|
baseFee.BigInt(),
|
||||||
@ -111,7 +111,7 @@ func (suite *BackendTestSuite) TestBaseFee() {
|
|||||||
"fail - base fee or london fork not enabled",
|
"fail - base fee or london fork not enabled",
|
||||||
&tmrpctypes.ResultBlockResults{Height: 1},
|
&tmrpctypes.ResultBlockResults{Height: 1},
|
||||||
func() {
|
func() {
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFeeDisabled(queryClient)
|
RegisterBaseFeeDisabled(queryClient)
|
||||||
},
|
},
|
||||||
nil,
|
nil,
|
||||||
@ -121,7 +121,7 @@ func (suite *BackendTestSuite) TestBaseFee() {
|
|||||||
"pass",
|
"pass",
|
||||||
&tmrpctypes.ResultBlockResults{Height: 1},
|
&tmrpctypes.ResultBlockResults{Height: 1},
|
||||||
func() {
|
func() {
|
||||||
queryClient := suite.backend.queryClient.QueryClient.(*mocks.QueryClient)
|
queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
|
||||||
RegisterBaseFee(queryClient, baseFee)
|
RegisterBaseFee(queryClient, baseFee)
|
||||||
},
|
},
|
||||||
baseFee.BigInt(),
|
baseFee.BigInt(),
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package backend
|
package backend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
@ -10,6 +11,7 @@ import (
|
|||||||
mock "github.com/stretchr/testify/mock"
|
mock "github.com/stretchr/testify/mock"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
abci "github.com/tendermint/tendermint/abci/types"
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
|
"github.com/tendermint/tendermint/libs/bytes"
|
||||||
tmrpcclient "github.com/tendermint/tendermint/rpc/client"
|
tmrpcclient "github.com/tendermint/tendermint/rpc/client"
|
||||||
tmrpctypes "github.com/tendermint/tendermint/rpc/core/types"
|
tmrpctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||||
"github.com/tendermint/tendermint/types"
|
"github.com/tendermint/tendermint/types"
|
||||||
@ -39,10 +41,10 @@ func RegisterBlock(
|
|||||||
|
|
||||||
// with tx
|
// with tx
|
||||||
block := types.MakeBlock(height, []types.Tx{tx}, nil, nil)
|
block := types.MakeBlock(height, []types.Tx{tx}, nil, nil)
|
||||||
res := &tmrpctypes.ResultBlock{Block: block}
|
resBlock := &tmrpctypes.ResultBlock{Block: block}
|
||||||
client.On("Block", rpc.ContextWithHeight(height), mock.AnythingOfType("*int64")).
|
client.On("Block", rpc.ContextWithHeight(height), mock.AnythingOfType("*int64")).
|
||||||
Return(res, nil)
|
Return(resBlock, nil)
|
||||||
return res, nil
|
return resBlock, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Block returns error
|
// Block returns error
|
||||||
@ -155,3 +157,13 @@ func RegisterBlockByHashNotFound(client *mocks.Client, hash common.Hash, tx []by
|
|||||||
client.On("BlockByHash", rpc.ContextWithHeight(1), []byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}).
|
client.On("BlockByHash", rpc.ContextWithHeight(1), []byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}).
|
||||||
Return(nil, nil)
|
Return(nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RegisterABCIQueryWithOptions(client *mocks.Client, height int64, path string, data bytes.HexBytes, opts tmrpcclient.ABCIQueryOptions) {
|
||||||
|
client.On("ABCIQueryWithOptions", context.Background(), path, data, opts).
|
||||||
|
Return(&tmrpctypes.ResultABCIQuery{
|
||||||
|
Response: abci.ResponseQuery{
|
||||||
|
Value: []byte{2}, // TODO replace with data.Bytes(),
|
||||||
|
Height: height,
|
||||||
|
},
|
||||||
|
}, nil)
|
||||||
|
}
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
|
grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/evmos/ethermint/rpc/backend/mocks"
|
"github.com/evmos/ethermint/rpc/backend/mocks"
|
||||||
rpc "github.com/evmos/ethermint/rpc/types"
|
rpc "github.com/evmos/ethermint/rpc/types"
|
||||||
"github.com/evmos/ethermint/tests"
|
"github.com/evmos/ethermint/tests"
|
||||||
@ -25,10 +26,10 @@ import (
|
|||||||
// to run a ethermint GRPC server.
|
// to run a ethermint GRPC server.
|
||||||
//
|
//
|
||||||
// To use a mock method it has to be registered in a given test.
|
// To use a mock method it has to be registered in a given test.
|
||||||
var _ evmtypes.QueryClient = &mocks.QueryClient{}
|
var _ evmtypes.QueryClient = &mocks.EVMQueryClient{}
|
||||||
|
|
||||||
// Params
|
// Params
|
||||||
func RegisterParams(queryClient *mocks.QueryClient, header *metadata.MD, height int64) {
|
func RegisterParams(queryClient *mocks.EVMQueryClient, header *metadata.MD, height int64) {
|
||||||
queryClient.On("Params", rpc.ContextWithHeight(height), &evmtypes.QueryParamsRequest{}, grpc.Header(header)).
|
queryClient.On("Params", rpc.ContextWithHeight(height), &evmtypes.QueryParamsRequest{}, grpc.Header(header)).
|
||||||
Return(&evmtypes.QueryParamsResponse{}, nil).
|
Return(&evmtypes.QueryParamsResponse{}, nil).
|
||||||
Run(func(args mock.Arguments) {
|
Run(func(args mock.Arguments) {
|
||||||
@ -40,7 +41,7 @@ func RegisterParams(queryClient *mocks.QueryClient, header *metadata.MD, height
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterParamsInvalidHeader(queryClient *mocks.QueryClient, header *metadata.MD, height int64) {
|
func RegisterParamsInvalidHeader(queryClient *mocks.EVMQueryClient, header *metadata.MD, height int64) {
|
||||||
queryClient.On("Params", rpc.ContextWithHeight(height), &evmtypes.QueryParamsRequest{}, grpc.Header(header)).
|
queryClient.On("Params", rpc.ContextWithHeight(height), &evmtypes.QueryParamsRequest{}, grpc.Header(header)).
|
||||||
Return(&evmtypes.QueryParamsResponse{}, nil).
|
Return(&evmtypes.QueryParamsResponse{}, nil).
|
||||||
Run(func(args mock.Arguments) {
|
Run(func(args mock.Arguments) {
|
||||||
@ -51,7 +52,7 @@ func RegisterParamsInvalidHeader(queryClient *mocks.QueryClient, header *metadat
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterParamsInvalidHeight(queryClient *mocks.QueryClient, header *metadata.MD, height int64) {
|
func RegisterParamsInvalidHeight(queryClient *mocks.EVMQueryClient, header *metadata.MD, height int64) {
|
||||||
queryClient.On("Params", rpc.ContextWithHeight(height), &evmtypes.QueryParamsRequest{}, grpc.Header(header)).
|
queryClient.On("Params", rpc.ContextWithHeight(height), &evmtypes.QueryParamsRequest{}, grpc.Header(header)).
|
||||||
Return(&evmtypes.QueryParamsResponse{}, nil).
|
Return(&evmtypes.QueryParamsResponse{}, nil).
|
||||||
Run(func(args mock.Arguments) {
|
Run(func(args mock.Arguments) {
|
||||||
@ -64,13 +65,13 @@ func RegisterParamsInvalidHeight(queryClient *mocks.QueryClient, header *metadat
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Params returns error
|
// Params returns error
|
||||||
func RegisterParamsError(queryClient *mocks.QueryClient, header *metadata.MD, height int64) {
|
func RegisterParamsError(queryClient *mocks.EVMQueryClient, header *metadata.MD, height int64) {
|
||||||
queryClient.On("Params", rpc.ContextWithHeight(height), &evmtypes.QueryParamsRequest{}, grpc.Header(header)).
|
queryClient.On("Params", rpc.ContextWithHeight(height), &evmtypes.QueryParamsRequest{}, grpc.Header(header)).
|
||||||
Return(nil, sdkerrors.ErrInvalidRequest)
|
Return(nil, sdkerrors.ErrInvalidRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRegisterParams(t *testing.T) {
|
func TestRegisterParams(t *testing.T) {
|
||||||
queryClient := mocks.NewQueryClient(t)
|
queryClient := mocks.NewEVMQueryClient(t)
|
||||||
var header metadata.MD
|
var header metadata.MD
|
||||||
height := int64(1)
|
height := int64(1)
|
||||||
RegisterParams(queryClient, &header, height)
|
RegisterParams(queryClient, &header, height)
|
||||||
@ -84,33 +85,33 @@ func TestRegisterParams(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRegisterParamsError(t *testing.T) {
|
func TestRegisterParamsError(t *testing.T) {
|
||||||
queryClient := mocks.NewQueryClient(t)
|
queryClient := mocks.NewEVMQueryClient(t)
|
||||||
RegisterBaseFeeError(queryClient)
|
RegisterBaseFeeError(queryClient)
|
||||||
_, err := queryClient.BaseFee(rpc.ContextWithHeight(1), &evmtypes.QueryBaseFeeRequest{})
|
_, err := queryClient.BaseFee(rpc.ContextWithHeight(1), &evmtypes.QueryBaseFeeRequest{})
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// BaseFee
|
// BaseFee
|
||||||
func RegisterBaseFee(queryClient *mocks.QueryClient, baseFee sdk.Int) {
|
func RegisterBaseFee(queryClient *mocks.EVMQueryClient, baseFee sdk.Int) {
|
||||||
queryClient.On("BaseFee", rpc.ContextWithHeight(1), &evmtypes.QueryBaseFeeRequest{}).
|
queryClient.On("BaseFee", rpc.ContextWithHeight(1), &evmtypes.QueryBaseFeeRequest{}).
|
||||||
Return(&evmtypes.QueryBaseFeeResponse{BaseFee: &baseFee}, nil)
|
Return(&evmtypes.QueryBaseFeeResponse{BaseFee: &baseFee}, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Base fee returns error
|
// Base fee returns error
|
||||||
func RegisterBaseFeeError(queryClient *mocks.QueryClient) {
|
func RegisterBaseFeeError(queryClient *mocks.EVMQueryClient) {
|
||||||
queryClient.On("BaseFee", rpc.ContextWithHeight(1), &evmtypes.QueryBaseFeeRequest{}).
|
queryClient.On("BaseFee", rpc.ContextWithHeight(1), &evmtypes.QueryBaseFeeRequest{}).
|
||||||
Return(&evmtypes.QueryBaseFeeResponse{}, evmtypes.ErrInvalidBaseFee)
|
Return(&evmtypes.QueryBaseFeeResponse{}, evmtypes.ErrInvalidBaseFee)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Base fee not enabled
|
// Base fee not enabled
|
||||||
func RegisterBaseFeeDisabled(queryClient *mocks.QueryClient) {
|
func RegisterBaseFeeDisabled(queryClient *mocks.EVMQueryClient) {
|
||||||
queryClient.On("BaseFee", rpc.ContextWithHeight(1), &evmtypes.QueryBaseFeeRequest{}).
|
queryClient.On("BaseFee", rpc.ContextWithHeight(1), &evmtypes.QueryBaseFeeRequest{}).
|
||||||
Return(&evmtypes.QueryBaseFeeResponse{}, nil)
|
Return(&evmtypes.QueryBaseFeeResponse{}, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRegisterBaseFee(t *testing.T) {
|
func TestRegisterBaseFee(t *testing.T) {
|
||||||
baseFee := sdk.NewInt(1)
|
baseFee := sdk.NewInt(1)
|
||||||
queryClient := mocks.NewQueryClient(t)
|
queryClient := mocks.NewEVMQueryClient(t)
|
||||||
RegisterBaseFee(queryClient, baseFee)
|
RegisterBaseFee(queryClient, baseFee)
|
||||||
res, err := queryClient.BaseFee(rpc.ContextWithHeight(1), &evmtypes.QueryBaseFeeRequest{})
|
res, err := queryClient.BaseFee(rpc.ContextWithHeight(1), &evmtypes.QueryBaseFeeRequest{})
|
||||||
require.Equal(t, &evmtypes.QueryBaseFeeResponse{BaseFee: &baseFee}, res)
|
require.Equal(t, &evmtypes.QueryBaseFeeResponse{BaseFee: &baseFee}, res)
|
||||||
@ -118,7 +119,7 @@ func TestRegisterBaseFee(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRegisterBaseFeeError(t *testing.T) {
|
func TestRegisterBaseFeeError(t *testing.T) {
|
||||||
queryClient := mocks.NewQueryClient(t)
|
queryClient := mocks.NewEVMQueryClient(t)
|
||||||
RegisterBaseFeeError(queryClient)
|
RegisterBaseFeeError(queryClient)
|
||||||
res, err := queryClient.BaseFee(rpc.ContextWithHeight(1), &evmtypes.QueryBaseFeeRequest{})
|
res, err := queryClient.BaseFee(rpc.ContextWithHeight(1), &evmtypes.QueryBaseFeeRequest{})
|
||||||
require.Equal(t, &evmtypes.QueryBaseFeeResponse{}, res)
|
require.Equal(t, &evmtypes.QueryBaseFeeResponse{}, res)
|
||||||
@ -126,7 +127,7 @@ func TestRegisterBaseFeeError(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRegisterBaseFeeDisabled(t *testing.T) {
|
func TestRegisterBaseFeeDisabled(t *testing.T) {
|
||||||
queryClient := mocks.NewQueryClient(t)
|
queryClient := mocks.NewEVMQueryClient(t)
|
||||||
RegisterBaseFeeDisabled(queryClient)
|
RegisterBaseFeeDisabled(queryClient)
|
||||||
res, err := queryClient.BaseFee(rpc.ContextWithHeight(1), &evmtypes.QueryBaseFeeRequest{})
|
res, err := queryClient.BaseFee(rpc.ContextWithHeight(1), &evmtypes.QueryBaseFeeRequest{})
|
||||||
require.Equal(t, &evmtypes.QueryBaseFeeResponse{}, res)
|
require.Equal(t, &evmtypes.QueryBaseFeeResponse{}, res)
|
||||||
@ -134,7 +135,7 @@ func TestRegisterBaseFeeDisabled(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ValidatorAccount
|
// ValidatorAccount
|
||||||
func RegisterValidatorAccount(queryClient *mocks.QueryClient, validator sdk.AccAddress) {
|
func RegisterValidatorAccount(queryClient *mocks.EVMQueryClient, validator sdk.AccAddress) {
|
||||||
queryClient.On("ValidatorAccount", rpc.ContextWithHeight(1), &evmtypes.QueryValidatorAccountRequest{}).
|
queryClient.On("ValidatorAccount", rpc.ContextWithHeight(1), &evmtypes.QueryValidatorAccountRequest{}).
|
||||||
Return(
|
Return(
|
||||||
&evmtypes.QueryValidatorAccountResponse{
|
&evmtypes.QueryValidatorAccountResponse{
|
||||||
@ -144,13 +145,13 @@ func RegisterValidatorAccount(queryClient *mocks.QueryClient, validator sdk.AccA
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterValidatorAccountError(queryClient *mocks.QueryClient) {
|
func RegisterValidatorAccountError(queryClient *mocks.EVMQueryClient) {
|
||||||
queryClient.On("ValidatorAccount", rpc.ContextWithHeight(1), &evmtypes.QueryValidatorAccountRequest{}).
|
queryClient.On("ValidatorAccount", rpc.ContextWithHeight(1), &evmtypes.QueryValidatorAccountRequest{}).
|
||||||
Return(nil, status.Error(codes.InvalidArgument, "empty request"))
|
Return(nil, status.Error(codes.InvalidArgument, "empty request"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRegisterValidatorAccount(t *testing.T) {
|
func TestRegisterValidatorAccount(t *testing.T) {
|
||||||
queryClient := mocks.NewQueryClient(t)
|
queryClient := mocks.NewEVMQueryClient(t)
|
||||||
|
|
||||||
validator := sdk.AccAddress(tests.GenerateAddress().Bytes())
|
validator := sdk.AccAddress(tests.GenerateAddress().Bytes())
|
||||||
RegisterValidatorAccount(queryClient, validator)
|
RegisterValidatorAccount(queryClient, validator)
|
||||||
@ -158,3 +159,57 @@ func TestRegisterValidatorAccount(t *testing.T) {
|
|||||||
require.Equal(t, &evmtypes.QueryValidatorAccountResponse{AccountAddress: validator.String()}, res)
|
require.Equal(t, &evmtypes.QueryValidatorAccountResponse{AccountAddress: validator.String()}, res)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Code
|
||||||
|
func RegisterCode(queryClient *mocks.EVMQueryClient, addr common.Address, code []byte) {
|
||||||
|
queryClient.On("Code", rpc.ContextWithHeight(1), &evmtypes.QueryCodeRequest{Address: addr.String()}).
|
||||||
|
Return(&evmtypes.QueryCodeResponse{Code: code}, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterCodeError(queryClient *mocks.EVMQueryClient, addr common.Address) {
|
||||||
|
queryClient.On("Code", rpc.ContextWithHeight(1), &evmtypes.QueryCodeRequest{Address: addr.String()}).
|
||||||
|
Return(nil, sdkerrors.ErrInvalidRequest)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Storage
|
||||||
|
func RegisterStorageAt(queryClient *mocks.EVMQueryClient, addr common.Address, key string, storage string) {
|
||||||
|
queryClient.On("Storage", rpc.ContextWithHeight(1), &evmtypes.QueryStorageRequest{Address: addr.String(), Key: key}).
|
||||||
|
Return(&evmtypes.QueryStorageResponse{Value: storage}, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterStorageAtError(queryClient *mocks.EVMQueryClient, addr common.Address, key string) {
|
||||||
|
queryClient.On("Storage", rpc.ContextWithHeight(1), &evmtypes.QueryStorageRequest{Address: addr.String(), Key: key}).
|
||||||
|
Return(nil, sdkerrors.ErrInvalidRequest)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterAccount(queryClient *mocks.EVMQueryClient, addr common.Address, height int64) {
|
||||||
|
queryClient.On("Account", rpc.ContextWithHeight(height), &evmtypes.QueryAccountRequest{Address: addr.String()}).
|
||||||
|
Return(&evmtypes.QueryAccountResponse{
|
||||||
|
Balance: "0",
|
||||||
|
CodeHash: "",
|
||||||
|
Nonce: 0,
|
||||||
|
},
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Balance
|
||||||
|
func RegisterBalance(queryClient *mocks.EVMQueryClient, addr common.Address, height int64) {
|
||||||
|
queryClient.On("Balance", rpc.ContextWithHeight(height), &evmtypes.QueryBalanceRequest{Address: addr.String()}).
|
||||||
|
Return(&evmtypes.QueryBalanceResponse{Balance: "1"}, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterBalanceInvalid(queryClient *mocks.EVMQueryClient, addr common.Address, height int64) {
|
||||||
|
queryClient.On("Balance", rpc.ContextWithHeight(height), &evmtypes.QueryBalanceRequest{Address: addr.String()}).
|
||||||
|
Return(&evmtypes.QueryBalanceResponse{Balance: "invalid"}, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterBalanceNegative(queryClient *mocks.EVMQueryClient, addr common.Address, height int64) {
|
||||||
|
queryClient.On("Balance", rpc.ContextWithHeight(height), &evmtypes.QueryBalanceRequest{Address: addr.String()}).
|
||||||
|
Return(&evmtypes.QueryBalanceResponse{Balance: "-1"}, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterBalanceError(queryClient *mocks.EVMQueryClient, addr common.Address, height int64) {
|
||||||
|
queryClient.On("Balance", rpc.ContextWithHeight(height), &evmtypes.QueryBalanceRequest{Address: addr.String()}).
|
||||||
|
Return(nil, sdkerrors.ErrInvalidRequest)
|
||||||
|
}
|
@ -12,13 +12,13 @@ import (
|
|||||||
types "github.com/evmos/ethermint/x/evm/types"
|
types "github.com/evmos/ethermint/x/evm/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// QueryClient is an autogenerated mock type for the QueryClient type
|
// EVMQueryClient is an autogenerated mock type for the EVMQueryClient type
|
||||||
type QueryClient struct {
|
type EVMQueryClient struct {
|
||||||
mock.Mock
|
mock.Mock
|
||||||
}
|
}
|
||||||
|
|
||||||
// Account provides a mock function with given fields: ctx, in, opts
|
// Account provides a mock function with given fields: ctx, in, opts
|
||||||
func (_m *QueryClient) Account(ctx context.Context, in *types.QueryAccountRequest, opts ...grpc.CallOption) (*types.QueryAccountResponse, error) {
|
func (_m *EVMQueryClient) Account(ctx context.Context, in *types.QueryAccountRequest, opts ...grpc.CallOption) (*types.QueryAccountResponse, error) {
|
||||||
_va := make([]interface{}, len(opts))
|
_va := make([]interface{}, len(opts))
|
||||||
for _i := range opts {
|
for _i := range opts {
|
||||||
_va[_i] = opts[_i]
|
_va[_i] = opts[_i]
|
||||||
@ -48,7 +48,7 @@ func (_m *QueryClient) Account(ctx context.Context, in *types.QueryAccountReques
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Balance provides a mock function with given fields: ctx, in, opts
|
// Balance provides a mock function with given fields: ctx, in, opts
|
||||||
func (_m *QueryClient) Balance(ctx context.Context, in *types.QueryBalanceRequest, opts ...grpc.CallOption) (*types.QueryBalanceResponse, error) {
|
func (_m *EVMQueryClient) Balance(ctx context.Context, in *types.QueryBalanceRequest, opts ...grpc.CallOption) (*types.QueryBalanceResponse, error) {
|
||||||
_va := make([]interface{}, len(opts))
|
_va := make([]interface{}, len(opts))
|
||||||
for _i := range opts {
|
for _i := range opts {
|
||||||
_va[_i] = opts[_i]
|
_va[_i] = opts[_i]
|
||||||
@ -78,7 +78,7 @@ func (_m *QueryClient) Balance(ctx context.Context, in *types.QueryBalanceReques
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BaseFee provides a mock function with given fields: ctx, in, opts
|
// BaseFee provides a mock function with given fields: ctx, in, opts
|
||||||
func (_m *QueryClient) BaseFee(ctx context.Context, in *types.QueryBaseFeeRequest, opts ...grpc.CallOption) (*types.QueryBaseFeeResponse, error) {
|
func (_m *EVMQueryClient) BaseFee(ctx context.Context, in *types.QueryBaseFeeRequest, opts ...grpc.CallOption) (*types.QueryBaseFeeResponse, error) {
|
||||||
_va := make([]interface{}, len(opts))
|
_va := make([]interface{}, len(opts))
|
||||||
for _i := range opts {
|
for _i := range opts {
|
||||||
_va[_i] = opts[_i]
|
_va[_i] = opts[_i]
|
||||||
@ -108,7 +108,7 @@ func (_m *QueryClient) BaseFee(ctx context.Context, in *types.QueryBaseFeeReques
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Code provides a mock function with given fields: ctx, in, opts
|
// Code provides a mock function with given fields: ctx, in, opts
|
||||||
func (_m *QueryClient) Code(ctx context.Context, in *types.QueryCodeRequest, opts ...grpc.CallOption) (*types.QueryCodeResponse, error) {
|
func (_m *EVMQueryClient) Code(ctx context.Context, in *types.QueryCodeRequest, opts ...grpc.CallOption) (*types.QueryCodeResponse, error) {
|
||||||
_va := make([]interface{}, len(opts))
|
_va := make([]interface{}, len(opts))
|
||||||
for _i := range opts {
|
for _i := range opts {
|
||||||
_va[_i] = opts[_i]
|
_va[_i] = opts[_i]
|
||||||
@ -138,7 +138,7 @@ func (_m *QueryClient) Code(ctx context.Context, in *types.QueryCodeRequest, opt
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CosmosAccount provides a mock function with given fields: ctx, in, opts
|
// CosmosAccount provides a mock function with given fields: ctx, in, opts
|
||||||
func (_m *QueryClient) CosmosAccount(ctx context.Context, in *types.QueryCosmosAccountRequest, opts ...grpc.CallOption) (*types.QueryCosmosAccountResponse, error) {
|
func (_m *EVMQueryClient) CosmosAccount(ctx context.Context, in *types.QueryCosmosAccountRequest, opts ...grpc.CallOption) (*types.QueryCosmosAccountResponse, error) {
|
||||||
_va := make([]interface{}, len(opts))
|
_va := make([]interface{}, len(opts))
|
||||||
for _i := range opts {
|
for _i := range opts {
|
||||||
_va[_i] = opts[_i]
|
_va[_i] = opts[_i]
|
||||||
@ -168,7 +168,7 @@ func (_m *QueryClient) CosmosAccount(ctx context.Context, in *types.QueryCosmosA
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EstimateGas provides a mock function with given fields: ctx, in, opts
|
// EstimateGas provides a mock function with given fields: ctx, in, opts
|
||||||
func (_m *QueryClient) EstimateGas(ctx context.Context, in *types.EthCallRequest, opts ...grpc.CallOption) (*types.EstimateGasResponse, error) {
|
func (_m *EVMQueryClient) EstimateGas(ctx context.Context, in *types.EthCallRequest, opts ...grpc.CallOption) (*types.EstimateGasResponse, error) {
|
||||||
_va := make([]interface{}, len(opts))
|
_va := make([]interface{}, len(opts))
|
||||||
for _i := range opts {
|
for _i := range opts {
|
||||||
_va[_i] = opts[_i]
|
_va[_i] = opts[_i]
|
||||||
@ -198,7 +198,7 @@ func (_m *QueryClient) EstimateGas(ctx context.Context, in *types.EthCallRequest
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EthCall provides a mock function with given fields: ctx, in, opts
|
// EthCall provides a mock function with given fields: ctx, in, opts
|
||||||
func (_m *QueryClient) EthCall(ctx context.Context, in *types.EthCallRequest, opts ...grpc.CallOption) (*types.MsgEthereumTxResponse, error) {
|
func (_m *EVMQueryClient) EthCall(ctx context.Context, in *types.EthCallRequest, opts ...grpc.CallOption) (*types.MsgEthereumTxResponse, error) {
|
||||||
_va := make([]interface{}, len(opts))
|
_va := make([]interface{}, len(opts))
|
||||||
for _i := range opts {
|
for _i := range opts {
|
||||||
_va[_i] = opts[_i]
|
_va[_i] = opts[_i]
|
||||||
@ -228,7 +228,7 @@ func (_m *QueryClient) EthCall(ctx context.Context, in *types.EthCallRequest, op
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Params provides a mock function with given fields: ctx, in, opts
|
// Params provides a mock function with given fields: ctx, in, opts
|
||||||
func (_m *QueryClient) Params(ctx context.Context, in *types.QueryParamsRequest, opts ...grpc.CallOption) (*types.QueryParamsResponse, error) {
|
func (_m *EVMQueryClient) Params(ctx context.Context, in *types.QueryParamsRequest, opts ...grpc.CallOption) (*types.QueryParamsResponse, error) {
|
||||||
_va := make([]interface{}, len(opts))
|
_va := make([]interface{}, len(opts))
|
||||||
for _i := range opts {
|
for _i := range opts {
|
||||||
_va[_i] = opts[_i]
|
_va[_i] = opts[_i]
|
||||||
@ -258,7 +258,7 @@ func (_m *QueryClient) Params(ctx context.Context, in *types.QueryParamsRequest,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Storage provides a mock function with given fields: ctx, in, opts
|
// Storage provides a mock function with given fields: ctx, in, opts
|
||||||
func (_m *QueryClient) Storage(ctx context.Context, in *types.QueryStorageRequest, opts ...grpc.CallOption) (*types.QueryStorageResponse, error) {
|
func (_m *EVMQueryClient) Storage(ctx context.Context, in *types.QueryStorageRequest, opts ...grpc.CallOption) (*types.QueryStorageResponse, error) {
|
||||||
_va := make([]interface{}, len(opts))
|
_va := make([]interface{}, len(opts))
|
||||||
for _i := range opts {
|
for _i := range opts {
|
||||||
_va[_i] = opts[_i]
|
_va[_i] = opts[_i]
|
||||||
@ -288,7 +288,7 @@ func (_m *QueryClient) Storage(ctx context.Context, in *types.QueryStorageReques
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TraceBlock provides a mock function with given fields: ctx, in, opts
|
// TraceBlock provides a mock function with given fields: ctx, in, opts
|
||||||
func (_m *QueryClient) TraceBlock(ctx context.Context, in *types.QueryTraceBlockRequest, opts ...grpc.CallOption) (*types.QueryTraceBlockResponse, error) {
|
func (_m *EVMQueryClient) TraceBlock(ctx context.Context, in *types.QueryTraceBlockRequest, opts ...grpc.CallOption) (*types.QueryTraceBlockResponse, error) {
|
||||||
_va := make([]interface{}, len(opts))
|
_va := make([]interface{}, len(opts))
|
||||||
for _i := range opts {
|
for _i := range opts {
|
||||||
_va[_i] = opts[_i]
|
_va[_i] = opts[_i]
|
||||||
@ -318,7 +318,7 @@ func (_m *QueryClient) TraceBlock(ctx context.Context, in *types.QueryTraceBlock
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TraceTx provides a mock function with given fields: ctx, in, opts
|
// TraceTx provides a mock function with given fields: ctx, in, opts
|
||||||
func (_m *QueryClient) TraceTx(ctx context.Context, in *types.QueryTraceTxRequest, opts ...grpc.CallOption) (*types.QueryTraceTxResponse, error) {
|
func (_m *EVMQueryClient) TraceTx(ctx context.Context, in *types.QueryTraceTxRequest, opts ...grpc.CallOption) (*types.QueryTraceTxResponse, error) {
|
||||||
_va := make([]interface{}, len(opts))
|
_va := make([]interface{}, len(opts))
|
||||||
for _i := range opts {
|
for _i := range opts {
|
||||||
_va[_i] = opts[_i]
|
_va[_i] = opts[_i]
|
||||||
@ -348,7 +348,7 @@ func (_m *QueryClient) TraceTx(ctx context.Context, in *types.QueryTraceTxReques
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ValidatorAccount provides a mock function with given fields: ctx, in, opts
|
// ValidatorAccount provides a mock function with given fields: ctx, in, opts
|
||||||
func (_m *QueryClient) ValidatorAccount(ctx context.Context, in *types.QueryValidatorAccountRequest, opts ...grpc.CallOption) (*types.QueryValidatorAccountResponse, error) {
|
func (_m *EVMQueryClient) ValidatorAccount(ctx context.Context, in *types.QueryValidatorAccountRequest, opts ...grpc.CallOption) (*types.QueryValidatorAccountResponse, error) {
|
||||||
_va := make([]interface{}, len(opts))
|
_va := make([]interface{}, len(opts))
|
||||||
for _i := range opts {
|
for _i := range opts {
|
||||||
_va[_i] = opts[_i]
|
_va[_i] = opts[_i]
|
||||||
@ -377,14 +377,14 @@ func (_m *QueryClient) ValidatorAccount(ctx context.Context, in *types.QueryVali
|
|||||||
return r0, r1
|
return r0, r1
|
||||||
}
|
}
|
||||||
|
|
||||||
type mockConstructorTestingTNewQueryClient interface {
|
type mockConstructorTestingTNewEVMQueryClient interface {
|
||||||
mock.TestingT
|
mock.TestingT
|
||||||
Cleanup(func())
|
Cleanup(func())
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewQueryClient creates a new instance of QueryClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
// NewEVMQueryClient creates a new instance of EVMQueryClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||||
func NewQueryClient(t mockConstructorTestingTNewQueryClient) *QueryClient {
|
func NewEVMQueryClient(t mockConstructorTestingTNewEVMQueryClient) *EVMQueryClient {
|
||||||
mock := &QueryClient{}
|
mock := &EVMQueryClient{}
|
||||||
mock.Mock.Test(t)
|
mock.Mock.Test(t)
|
||||||
|
|
||||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
t.Cleanup(func() { mock.AssertExpectations(t) })
|
Loading…
Reference in New Issue
Block a user