mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-05 13:05:09 +00:00
fix linter errors thrown by unconvert, goconst, and nakedret (#3960)
* Remove unnecessary type conversions * Consolidate repeated strings into consts * Clothe return statements * Update blockchain/v1/reactor_fsm_test.go Co-Authored-By: Anton Kaliaev <anton.kalyaev@gmail.com> This PR repairs linter errors seen when running the following commands: golangci-lint run --no-config --disable-all=true --enable=unconvert golangci-lint run --no-config --disable-all=true --enable=goconst golangci-lint run --no-config --disable-all=true --enable=nakedret Contributes to #3262
This commit is contained in:
committed by
Anton Kaliaev
parent
7f0c55f249
commit
04d13d9945
@@ -559,7 +559,7 @@ func makeEvidences(t *testing.T, val *privval.FilePV, chainID string) (ev types.
|
||||
// exactly same vote
|
||||
vote2 = deepcpVote(vote)
|
||||
fakes[41] = newEvidence(t, val, vote, vote2, chainID)
|
||||
return
|
||||
return ev, fakes
|
||||
}
|
||||
|
||||
func TestBroadcastEvidenceDuplicateVote(t *testing.T) {
|
||||
|
||||
@@ -106,7 +106,7 @@ func Tx(ctx *rpctypes.Context, hash []byte, prove bool) (*ctypes.ResultTx, error
|
||||
return &ctypes.ResultTx{
|
||||
Hash: hash,
|
||||
Height: height,
|
||||
Index: uint32(index),
|
||||
Index: index,
|
||||
TxResult: r.Result,
|
||||
Tx: r.Tx,
|
||||
Proof: proof,
|
||||
|
||||
@@ -33,6 +33,8 @@ const (
|
||||
unixAddr = "unix://" + unixSocket
|
||||
|
||||
websocketEndpoint = "/websocket/endpoint"
|
||||
|
||||
testVal = "acbd"
|
||||
)
|
||||
|
||||
type ResultEcho struct {
|
||||
@@ -189,7 +191,7 @@ func echoDataBytesViaHTTP(cl client.HTTPClient, bytes cmn.HexBytes) (cmn.HexByte
|
||||
}
|
||||
|
||||
func testWithHTTPClient(t *testing.T, cl client.HTTPClient) {
|
||||
val := "acbd"
|
||||
val := testVal
|
||||
got, err := echoViaHTTP(cl, val)
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, got, val)
|
||||
@@ -255,7 +257,7 @@ func echoBytesViaWS(cl *client.WSClient, bytes []byte) ([]byte, error) {
|
||||
}
|
||||
|
||||
func testWithWSClient(t *testing.T, cl *client.WSClient) {
|
||||
val := "acbd"
|
||||
val := testVal
|
||||
got, err := echoViaWS(cl, val)
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, got, val)
|
||||
@@ -314,7 +316,7 @@ func TestWSNewWSRPCFunc(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
defer cl.Stop()
|
||||
|
||||
val := "acbd"
|
||||
val := testVal
|
||||
params := map[string]interface{}{
|
||||
"arg": val,
|
||||
}
|
||||
@@ -339,7 +341,7 @@ func TestWSHandlesArrayParams(t *testing.T) {
|
||||
require.Nil(t, err)
|
||||
defer cl.Stop()
|
||||
|
||||
val := "acbd"
|
||||
val := testVal
|
||||
params := []interface{}{val}
|
||||
err = cl.CallWithArrayParams(context.Background(), "echo_ws", params)
|
||||
require.Nil(t, err)
|
||||
|
||||
@@ -376,9 +376,9 @@ func _nonJSONStringToArg(cdc *amino.Codec, rt reflect.Type, arg string) (reflect
|
||||
rv, err := jsonStringToArg(cdc, rt, qarg)
|
||||
if err != nil {
|
||||
return rv, err, false
|
||||
} else {
|
||||
return rv, nil, true
|
||||
}
|
||||
|
||||
return rv, nil, true
|
||||
}
|
||||
|
||||
if isHexString {
|
||||
@@ -396,7 +396,7 @@ func _nonJSONStringToArg(cdc *amino.Codec, rt reflect.Type, arg string) (reflect
|
||||
if rt.Kind() == reflect.String {
|
||||
return reflect.ValueOf(string(value)), nil, true
|
||||
}
|
||||
return reflect.ValueOf([]byte(value)), nil, true
|
||||
return reflect.ValueOf(value), nil, true
|
||||
}
|
||||
|
||||
if isQuotedString && expectingByteSlice {
|
||||
|
||||
@@ -39,17 +39,17 @@ func TestResponses(t *testing.T) {
|
||||
a := NewRPCSuccessResponse(cdc, jsonid, &SampleResult{"hello"})
|
||||
b, _ := json.Marshal(a)
|
||||
s := fmt.Sprintf(`{"jsonrpc":"2.0","id":%v,"result":{"Value":"hello"}}`, tt.expected)
|
||||
assert.Equal(string(s), string(b))
|
||||
assert.Equal(s, string(b))
|
||||
|
||||
d := RPCParseError(jsonid, errors.New("Hello world"))
|
||||
e, _ := json.Marshal(d)
|
||||
f := fmt.Sprintf(`{"jsonrpc":"2.0","id":%v,"error":{"code":-32700,"message":"Parse error. Invalid JSON","data":"Hello world"}}`, tt.expected)
|
||||
assert.Equal(string(f), string(e))
|
||||
assert.Equal(f, string(e))
|
||||
|
||||
g := RPCMethodNotFoundError(jsonid)
|
||||
h, _ := json.Marshal(g)
|
||||
i := fmt.Sprintf(`{"jsonrpc":"2.0","id":%v,"error":{"code":-32601,"message":"Method not found"}}`, tt.expected)
|
||||
assert.Equal(string(h), string(i))
|
||||
assert.Equal(string(h), i)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user