Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

eth_sendTransaction returns internal trace on missing param #1284

Merged
merged 13 commits into from
Aug 25, 2022
4 changes: 2 additions & 2 deletions rpc/backend/sign_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (
// SendTransaction sends transaction based on received args using Node's key to sign it
func (b *Backend) SendTransaction(args evmtypes.TransactionArgs) (common.Hash, error) {
// Look up the wallet containing the requested signer
_, err := b.clientCtx.Keyring.KeyByAddress(sdk.AccAddress(args.From.Bytes()))
_, err := b.clientCtx.Keyring.KeyByAddress(sdk.AccAddress(args.GetFrom().Bytes()))
if err != nil {
b.logger.Error("failed to find key in keyring", "address", args.From, "error", err.Error())
b.logger.Error("failed to find key in keyring", "address", args.GetFrom(), "error", err.Error())
return common.Hash{}, fmt.Errorf("%s; %s", keystore.ErrNoMatch, err.Error())
}

Expand Down
1 change: 1 addition & 0 deletions rpc/websockets.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func (s *websocketsServer) Start() {

go func() {
var err error
/* #nosec G114 -- no support for timeouts */
if s.certFile == "" || s.keyFile == "" {
err = http.ListenAndServe(s.wsAddr, ws)
} else {
Expand Down
20 changes: 20 additions & 0 deletions tests/rpc/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,26 @@ func waitForReceipt(t *testing.T, hash hexutil.Bytes) map[string]interface{} {
}
}

func TestEth_IncompleteSendTransaction(t *testing.T) {
// get gasprice
gasPrice := GetGasPrice(t)

// make tx params without from address
param := make([]map[string]string, 1)
param[0] = make(map[string]string)
param[0]["from"] = ""
param[0]["to"] = "0x1122334455667788990011223344556677889900"
param[0]["value"] = "0x1"
param[0]["gasPrice"] = gasPrice
_, err := callWithError("eth_sendTransaction", param)

// require well-formatted error (should not be "method handler crashed")
require.Error(t, err)
require.NotEqual(t, err.Error(), "method handler crashed", "no from field dealt with incorrectly")
fmt.Println(err.Error())
return
facs95 marked this conversation as resolved.
Show resolved Hide resolved
}

func TestEth_GetFilterChanges_NoTopics(t *testing.T) {
rpcRes := call(t, "eth_blockNumber", []string{})

Expand Down