From 0dcbfb7d0fba927a64c792d15e9673615bc97f58 Mon Sep 17 00:00:00 2001 From: skosito Date: Fri, 31 May 2024 01:16:35 +0200 Subject: [PATCH] cleanup --- rpc/backend/call_tx_test.go | 9 ++++++--- rpc/backend/sign_tx_test.go | 16 +++++++++++----- rpc/backend/tracing_test.go | 15 ++++++++++----- rpc/backend/tx_info_test.go | 17 ++++++++++++----- 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/rpc/backend/call_tx_test.go b/rpc/backend/call_tx_test.go index 41899b0b80..d38b2c6635 100644 --- a/rpc/backend/call_tx_test.go +++ b/rpc/backend/call_tx_test.go @@ -271,9 +271,12 @@ func (suite *BackendTestSuite) TestResend() { func (suite *BackendTestSuite) TestSendRawTransaction() { ethTx, bz := suite.buildEthereumTx() - rlpEncodedBz, _ := rlp.EncodeToBytes(ethTx.AsTransaction()) - cosmosTx, _ := ethTx.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "aphoton") - txBytes, _ := suite.backend.clientCtx.TxConfig.TxEncoder()(cosmosTx) + rlpEncodedBz, err := rlp.EncodeToBytes(ethTx.AsTransaction()) + suite.Require().NoError(err) + cosmosTx, err := ethTx.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "aphoton") + suite.Require().NoError(err) + txBytes, err := suite.backend.clientCtx.TxConfig.TxEncoder()(cosmosTx) + suite.Require().NoError(err) testCases := []struct { name string diff --git a/rpc/backend/sign_tx_test.go b/rpc/backend/sign_tx_test.go index eccf9ee131..e746a3d781 100644 --- a/rpc/backend/sign_tx_test.go +++ b/rpc/backend/sign_tx_test.go @@ -22,7 +22,8 @@ func (suite *BackendTestSuite) TestSendTransaction() { gas := hexutil.Uint64(1) zeroGas := hexutil.Uint64(0) toAddr := tests.GenerateAddress() - priv, _ := ethsecp256k1.GenerateKey() + priv, err := ethsecp256k1.GenerateKey() + suite.Require().NoError(err) from := common.BytesToAddress(priv.PubKey().Address().Bytes()) nonce := hexutil.Uint64(1) baseFee := sdk.NewInt(1) @@ -104,9 +105,11 @@ func (suite *BackendTestSuite) TestSendTransaction() { ethSigner := ethtypes.LatestSigner(suite.backend.ChainConfig()) msg := callArgsDefault.ToTransaction() msg.Sign(ethSigner, suite.backend.clientCtx.Keyring) - tx, _ := msg.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "aphoton") + tx, err := msg.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "aphoton") + suite.Require().NoError(err) txEncoder := suite.backend.clientCtx.TxConfig.TxEncoder() - txBytes, _ := txEncoder(tx) + txBytes, err := txEncoder(tx) + suite.Require().NoError(err) RegisterBroadcastTxError(client, txBytes) }, callArgsDefault, @@ -129,9 +132,11 @@ func (suite *BackendTestSuite) TestSendTransaction() { ethSigner := ethtypes.LatestSigner(suite.backend.ChainConfig()) msg := callArgsDefault.ToTransaction() msg.Sign(ethSigner, suite.backend.clientCtx.Keyring) - tx, _ := msg.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "aphoton") + tx, err := msg.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "aphoton") + suite.Require().NoError(err) txEncoder := suite.backend.clientCtx.TxConfig.TxEncoder() - txBytes, _ := txEncoder(tx) + txBytes, err := txEncoder(tx) + suite.Require().NoError(err) RegisterBroadcastTx(client, txBytes) }, callArgsDefault, @@ -249,6 +254,7 @@ func (suite *BackendTestSuite) TestSignTypedData() { if tc.expPass { sigHash, _, err := apitypes.TypedDataAndHash(tc.inputTypedData) + suite.Require().NoError(err) signature, _, err := suite.backend.clientCtx.Keyring.SignByAddress((sdk.AccAddress)(from.Bytes()), sigHash) signature[goethcrypto.RecoveryIDOffset] += 27 suite.Require().NoError(err) diff --git a/rpc/backend/tracing_test.go b/rpc/backend/tracing_test.go index 020f9a2db8..0c27e980e6 100644 --- a/rpc/backend/tracing_test.go +++ b/rpc/backend/tracing_test.go @@ -24,7 +24,8 @@ func (suite *BackendTestSuite) TestTraceTransaction() { txHash := msgEthereumTx.AsTransaction().Hash() txHash2 := msgEthereumTx2.AsTransaction().Hash() - priv, _ := ethsecp256k1.GenerateKey() + priv, err := ethsecp256k1.GenerateKey() + suite.Require().NoError(err) from := common.BytesToAddress(priv.PubKey().Address().Bytes()) queryClient := suite.backend.queryClient.QueryClient.(*mocks.EVMQueryClient) @@ -38,13 +39,17 @@ func (suite *BackendTestSuite) TestTraceTransaction() { msgEthereumTx.From = from.String() msgEthereumTx.Sign(ethSigner, suite.signer) - tx, _ := msgEthereumTx.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "aphoton") - txBz, _ := txEncoder(tx) + tx, err := msgEthereumTx.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "aphoton") + suite.Require().NoError(err) + txBz, err := txEncoder(tx) + suite.Require().NoError(err) msgEthereumTx2.From = from.String() msgEthereumTx2.Sign(ethSigner, suite.signer) - tx2, _ := msgEthereumTx2.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "aphoton") - txBz2, _ := txEncoder(tx2) + tx2, err := msgEthereumTx2.BuildTx(suite.backend.clientCtx.TxConfig.NewTxBuilder(), "aphoton") + suite.Require().NoError(err) + txBz2, err := txEncoder(tx2) + suite.Require().NoError(err) testCases := []struct { name string diff --git a/rpc/backend/tx_info_test.go b/rpc/backend/tx_info_test.go index 5078eefcb0..ac33651e2b 100644 --- a/rpc/backend/tx_info_test.go +++ b/rpc/backend/tx_info_test.go @@ -42,7 +42,8 @@ func (suite *BackendTestSuite) TestGetTransactionByHash() { }, } - rpcTransaction, _ := rpctypes.NewRPCTransaction(msgEthereumTx.AsTransaction(), common.Hash{}, 0, 0, big.NewInt(1), suite.backend.chainID) + rpcTransaction, err := rpctypes.NewRPCTransaction(msgEthereumTx.AsTransaction(), common.Hash{}, 0, 0, big.NewInt(1), suite.backend.chainID) + suite.Require().NoError(err) testCases := []struct { name string @@ -124,7 +125,8 @@ func (suite *BackendTestSuite) TestGetTransactionByHash() { func (suite *BackendTestSuite) TestGetTransactionsByHashPending() { msgEthereumTx, bz := suite.buildEthereumTx() - rpcTransaction, _ := rpctypes.NewRPCTransaction(msgEthereumTx.AsTransaction(), common.Hash{}, 0, 0, big.NewInt(1), suite.backend.chainID) + rpcTransaction, err := rpctypes.NewRPCTransaction(msgEthereumTx.AsTransaction(), common.Hash{}, 0, 0, big.NewInt(1), suite.backend.chainID) + suite.Require().NoError(err) testCases := []struct { name string @@ -184,7 +186,8 @@ func (suite *BackendTestSuite) TestGetTransactionsByHashPending() { func (suite *BackendTestSuite) TestGetTxByEthHash() { msgEthereumTx, bz := suite.buildEthereumTx() - rpcTransaction, _ := rpctypes.NewRPCTransaction(msgEthereumTx.AsTransaction(), common.Hash{}, 0, 0, big.NewInt(1), suite.backend.chainID) + rpcTransaction, err := rpctypes.NewRPCTransaction(msgEthereumTx.AsTransaction(), common.Hash{}, 0, 0, big.NewInt(1), suite.backend.chainID) + suite.Require().NoError(err) testCases := []struct { name string @@ -294,7 +297,7 @@ func (suite *BackendTestSuite) TestGetTransactionByBlockAndIndex() { }, } - txFromMsg, _ := rpctypes.NewTransactionFromMsg( + txFromMsg, err := rpctypes.NewTransactionFromMsg( msgEthTx, common.BytesToHash(defaultBlock.Hash().Bytes()), 1, @@ -303,6 +306,8 @@ func (suite *BackendTestSuite) TestGetTransactionByBlockAndIndex() { suite.backend.chainID, nil, ) + suite.Require().NoError(err) + testCases := []struct { name string registerMock func() @@ -389,7 +394,7 @@ func (suite *BackendTestSuite) TestGetTransactionByBlockAndIndex() { func (suite *BackendTestSuite) TestGetTransactionByBlockNumberAndIndex() { msgEthTx, bz := suite.buildEthereumTx() defaultBlock := types.MakeBlock(1, []types.Tx{bz}, nil, nil) - txFromMsg, _ := rpctypes.NewTransactionFromMsg( + txFromMsg, err := rpctypes.NewTransactionFromMsg( msgEthTx, common.BytesToHash(defaultBlock.Hash().Bytes()), 1, @@ -398,6 +403,8 @@ func (suite *BackendTestSuite) TestGetTransactionByBlockNumberAndIndex() { suite.backend.chainID, nil, ) + suite.Require().NoError(err) + testCases := []struct { name string registerMock func()