From b91a437b09cff717d2cc36bbf385c412057d41cd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 15:58:03 +0000 Subject: [PATCH] cmd/pushtx: address code review feedback Co-authored-by: drQedwards <213266729+drQedwards@users.noreply.github.com> --- cmd/pushtx/main.go | 2 +- cmd/pushtx/main_test.go | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cmd/pushtx/main.go b/cmd/pushtx/main.go index 674176a996..eb936c7850 100644 --- a/cmd/pushtx/main.go +++ b/cmd/pushtx/main.go @@ -85,7 +85,7 @@ func run(args []string, stdin io.Reader) error { txHex = strings.TrimSpace(string(data)) } if txHex == "" { - return fmt.Errorf("no transaction data provided\nUsage: pushtx [--rpc URL] ") + return fmt.Errorf("no transaction data provided (see --help for usage)") } rawTx, err := hex.DecodeString(strings.TrimPrefix(txHex, "0x")) diff --git a/cmd/pushtx/main_test.go b/cmd/pushtx/main_test.go index 101c3e8a22..972edf100b 100644 --- a/cmd/pushtx/main_test.go +++ b/cmd/pushtx/main_test.go @@ -98,10 +98,20 @@ func fakeRPC(t *testing.T, wantErr bool) *httptest.Server { } // Decode the raw tx to return its hash as the result. var hexData string - json.Unmarshal(req.Params[0], &hexData) - rawBytes, _ := hexutil.Decode(hexData) + if err := json.Unmarshal(req.Params[0], &hexData); err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + rawBytes, err := hexutil.Decode(hexData) + if err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } var tx types.Transaction - tx.UnmarshalBinary(rawBytes) + if err := tx.UnmarshalBinary(rawBytes); err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } json.NewEncoder(w).Encode(map[string]interface{}{ "jsonrpc": "2.0", "id": req.ID,