Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Jun 3, 2024
1 parent cb0a191 commit 38738b4
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 24 deletions.
2 changes: 1 addition & 1 deletion rpc/backend/account_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ func (suite *BackendTestSuite) TestGetTransactionCount() {
false,
hexutil.Uint64(0),
},
// TODO: Error mocking the GetAccount call - problem with Any type
// TODO (https://github.com/zeta-chain/node/issues/2302): Error mocking the GetAccount call - problem with Any type
//{
// "pass - returns the number of transactions at the given address up to the given block number",
// true,
Expand Down
4 changes: 2 additions & 2 deletions rpc/backend/backend_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestBackendTestSuite(t *testing.T) {
suite.Run(t, new(BackendTestSuite))
}

const ChainID = "ethermint_9000-1"
const ChainID = "zetachain_7001-1"

// SetupTest is executed before every BackendTestSuite test
func (suite *BackendTestSuite) SetupTest() {
Expand Down Expand Up @@ -188,7 +188,7 @@ func (suite *BackendTestSuite) signAndEncodeEthTx(msgEthereumTx *evmtypes.MsgEth
err := msgEthereumTx.Sign(ethSigner, signer)
suite.Require().NoError(err)

tx, err := msgEthereumTx.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "aphoton")
tx, err := msgEthereumTx.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "azeta")
suite.Require().NoError(err)

txEncoder := suite.backend.clientCtx.TxConfig.TxEncoder()
Expand Down
2 changes: 1 addition & 1 deletion rpc/backend/call_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func (suite *BackendTestSuite) TestSendRawTransaction() {
ethTx, bz := suite.buildEthereumTx()
rlpEncodedBz, err := rlp.EncodeToBytes(ethTx.AsTransaction())
suite.Require().NoError(err)
cosmosTx, err := ethTx.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "aphoton")
cosmosTx, err := ethTx.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "azeta")
suite.Require().NoError(err)
txBytes, err := suite.backend.clientCtx.TxConfig.TxEncoder()(cosmosTx)
suite.Require().NoError(err)
Expand Down
2 changes: 1 addition & 1 deletion rpc/backend/chain_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (suite *BackendTestSuite) TestBaseFee() {
}

func (suite *BackendTestSuite) TestChainId() {
expChainId := (*hexutil.Big)(big.NewInt(9000))
expChainId := (*hexutil.Big)(big.NewInt(7001))
testCases := []struct {
name string
registerMock func()
Expand Down
2 changes: 1 addition & 1 deletion rpc/backend/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func RegisterABCIQueryWithOptions(
client.On("ABCIQueryWithOptions", context.Background(), path, data, opts).
Return(&tmrpctypes.ResultABCIQuery{
Response: abci.ResponseQuery{
Value: []byte{2}, // TODO replace with data.Bytes(),
Value: []byte{2}, // TODO (https://github.com/zeta-chain/node/issues/2302) replace with data.Bytes(),
Height: height,
},
}, nil)
Expand Down
12 changes: 7 additions & 5 deletions rpc/backend/evm_query_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ func RegisterTraceTransactionWithPredecessors(
) {
data := []byte{0x7b, 0x22, 0x74, 0x65, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x7d}
queryClient.On("TraceTx", rpc.ContextWithHeight(1),
&evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, Predecessors: predecessors, ChainId: 9000}).
&evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, Predecessors: predecessors, ChainId: 7001}).
Return(&evmtypes.QueryTraceTxResponse{Data: data}, nil)
}

func RegisterTraceTransaction(queryClient *mocks.EVMQueryClient, msgEthTx *evmtypes.MsgEthereumTx) {
data := []byte{0x7b, 0x22, 0x74, 0x65, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x7d}
queryClient.On("TraceTx", rpc.ContextWithHeight(1), &evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, Predecessors: []*evmtypes.MsgEthereumTx{}, ChainId: 9000}).
queryClient.On("TraceTx", rpc.ContextWithHeight(1), &evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, Predecessors: []*evmtypes.MsgEthereumTx{}, ChainId: 7001}).
Return(&evmtypes.QueryTraceTxResponse{Data: data}, nil)
}

func RegisterTraceTransactionError(queryClient *mocks.EVMQueryClient, msgEthTx *evmtypes.MsgEthereumTx) {
queryClient.On("TraceTx", rpc.ContextWithHeight(1), &evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, ChainId: 9000}).
queryClient.On("TraceTx", rpc.ContextWithHeight(1), &evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, ChainId: 7001}).
Return(nil, errortypes.ErrInvalidRequest)
}

Expand All @@ -65,7 +65,7 @@ func RegisterTraceBlock(queryClient *mocks.EVMQueryClient, txs []*evmtypes.MsgEt
Txs: txs,
BlockNumber: 1,
TraceConfig: &evmtypes.TraceConfig{},
ChainId: 9000,
ChainId: 7001,
},
).
Return(&evmtypes.QueryTraceBlockResponse{Data: data}, nil)
Expand All @@ -90,8 +90,10 @@ func RegisterParams(queryClient *mocks.EVMQueryClient, header *metadata.MD, heig
}

func RegisterParamsWithoutHeader(queryClient *mocks.EVMQueryClient, height int64) {
params := evmtypes.DefaultParams()
params.EvmDenom = "azeta"
queryClient.On("Params", rpc.ContextWithHeight(height), &evmtypes.QueryParamsRequest{}).
Return(&evmtypes.QueryParamsResponse{Params: evmtypes.DefaultParams()}, nil)
Return(&evmtypes.QueryParamsResponse{Params: params}, nil)
}

func RegisterParamsInvalidHeader(queryClient *mocks.EVMQueryClient, header *metadata.MD, height int64) {
Expand Down
8 changes: 4 additions & 4 deletions rpc/backend/node_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (suite *BackendTestSuite) TestSetGasPrice() {
}
}

// TODO: Combine these 2 into one test since the code is identical
// TODO (https://github.com/zeta-chain/node/issues/2302): Combine these 2 into one test since the code is identical
func (suite *BackendTestSuite) TestListAccounts() {
testCases := []struct {
name string
Expand Down Expand Up @@ -255,7 +255,7 @@ func (suite *BackendTestSuite) TestSetEtherbase() {
RegisterStatus(client)
RegisterValidatorAccount(queryClient, suite.acc)
RegisterParams(queryClient, &header, 1)
c := sdk.NewDecCoin("aphoton", sdk.NewIntFromBigInt(big.NewInt(1)))
c := sdk.NewDecCoin("azeta", sdk.NewIntFromBigInt(big.NewInt(1)))
suite.backend.cfg.SetMinGasPrices(sdk.DecCoins{c})
delAddr, _ := suite.backend.GetCoinbase()
// account, _ := suite.backend.clientCtx.AccountRetriever.GetAccount(suite.backend.clientCtx, delAddr)
Expand All @@ -272,15 +272,15 @@ func (suite *BackendTestSuite) TestSetEtherbase() {
common.Address{},
false,
},
// TODO: Finish this test case once ABCIQuery GetAccount is fixed
// TODO (https://github.com/zeta-chain/node/issues/2302): Finish this test case once ABCIQuery GetAccount is fixed
//{
// "pass - set the etherbase for the miner",
// func() {
// client := suite.backend.clientCtx.Client.(*mocks.Client)
// queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient)
// RegisterStatus(client)
// RegisterValidatorAccount(queryClient, suite.acc)
// c := sdk.NewDecCoin("aphoton", sdk.NewIntFromBigInt(big.NewInt(1)))
// c := sdk.NewDecCoin("azeta", sdk.NewIntFromBigInt(big.NewInt(1)))
// suite.backend.cfg.SetMinGasPrices(sdk.DecCoins{c})
// delAddr, _ := suite.backend.GetCoinbase()
// account, _ := suite.backend.clientCtx.AccountRetriever.GetAccount(suite.backend.clientCtx, delAddr)
Expand Down
6 changes: 3 additions & 3 deletions rpc/backend/sign_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (suite *BackendTestSuite) TestSendTransaction() {
ethSigner := ethtypes.LatestSigner(suite.backend.ChainConfig())
msg := callArgsDefault.ToTransaction()
msg.Sign(ethSigner, suite.backend.clientCtx.Keyring)
tx, err := msg.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "aphoton")
tx, err := msg.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "azeta")
suite.Require().NoError(err)
txEncoder := suite.backend.clientCtx.TxConfig.TxEncoder()
txBytes, err := txEncoder(tx)
Expand All @@ -133,7 +133,7 @@ func (suite *BackendTestSuite) TestSendTransaction() {
ethSigner := ethtypes.LatestSigner(suite.backend.ChainConfig())
msg := callArgsDefault.ToTransaction()
msg.Sign(ethSigner, suite.backend.clientCtx.Keyring)
tx, err := msg.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "aphoton")
tx, err := msg.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "azeta")
suite.Require().NoError(err)
txEncoder := suite.backend.clientCtx.TxConfig.TxEncoder()
txBytes, err := txEncoder(tx)
Expand Down Expand Up @@ -246,7 +246,7 @@ func (suite *BackendTestSuite) TestSignTypedData() {
apitypes.TypedData{},
false,
},
// TODO: Generate a TypedData msg
// TODO (https://github.com/zeta-chain/node/issues/2302): Generate a TypedData msg
}

for _, tc := range testCases {
Expand Down
4 changes: 2 additions & 2 deletions rpc/backend/tracing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ func (suite *BackendTestSuite) TestTraceTransaction() {

msgEthereumTx.From = from.String()
msgEthereumTx.Sign(ethSigner, suite.signer)
tx, err := msgEthereumTx.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "aphoton")
tx, err := msgEthereumTx.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "azeta")
suite.Require().NoError(err)
txBz, err := txEncoder(tx)
suite.Require().NoError(err)

msgEthereumTx2.From = from.String()
msgEthereumTx2.Sign(ethSigner, suite.signer)
tx2, err := msgEthereumTx2.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "aphoton")
tx2, err := msgEthereumTx2.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "azeta")
suite.Require().NoError(err)
txBz2, err := txEncoder(tx2)
suite.Require().NoError(err)
Expand Down
8 changes: 4 additions & 4 deletions rpc/backend/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/cometbft/cometbft/proto/tendermint/crypto"
)

func mookProofs(num int, withData bool) *crypto.ProofOps {
func mockProofs(num int, withData bool) *crypto.ProofOps {
var proofOps *crypto.ProofOps
if num > 0 {
proofOps = new(crypto.ProofOps)
Expand All @@ -30,17 +30,17 @@ func (suite *BackendTestSuite) TestGetHexProofs() {
}{
{
"no proof provided",
mookProofs(0, false),
mockProofs(0, false),
defaultRes,
},
{
"no proof data provided",
mookProofs(1, false),
mockProofs(1, false),
defaultRes,
},
{
"valid proof provided",
mookProofs(1, true),
mockProofs(1, true),
[]string{"0x0a190a034b4559120556414c55451a0b0801180120012a03000202"},
},
}
Expand Down

0 comments on commit 38738b4

Please sign in to comment.