linters: modify code to pass maligned and interfacer (#3959)

* Fix maligned structs

* Fix interfacer errors

* Revert accidental go.mod and go.sum changes

* Revert P2PConfig struct maligned reorder

* Revert PeerRoundState struct maligned reordering

* Revert RoundState struct maligned reordering

* Reorder WSClient struct

* Revert accidental type change

* Clean up type change

* Clean up type changes

* Revert to types.ABCIApplicationServer in GRPCServer struct

* Revert maligned changes to BaseConfig struct

* Fix tests in io_test.go

* Fix client_test package tests

* Fix reactor tests in consensus package

* Fix new interfacer errors
This commit is contained in:
Phil Salant
2019-09-30 17:12:51 -07:00
committed by Anton Kaliaev
parent 68f8fba7c2
commit 05075ea5b7
25 changed files with 128 additions and 127 deletions
+7 -7
View File
@@ -364,16 +364,16 @@ func TestTx(t *testing.T) {
cases := []struct {
valid bool
hash []byte
prove bool
hash []byte
}{
// only valid if correct hash provided
{true, txHash, false},
{true, txHash, true},
{false, anotherTxHash, false},
{false, anotherTxHash, true},
{false, nil, false},
{false, nil, true},
{true, false, txHash},
{true, true, txHash},
{false, false, anotherTxHash},
{false, true, anotherTxHash},
{false, false, nil},
{false, true, nil},
}
for i, c := range GetClients() {
+11 -11
View File
@@ -28,8 +28,6 @@ const (
// WSClient is a WebSocket client. The methods of WSClient are safe for use by
// multiple goroutines.
type WSClient struct {
cmn.BaseService
conn *websocket.Conn
cdc *amino.Codec
@@ -37,10 +35,6 @@ type WSClient struct {
Endpoint string // /websocket/url/endpoint
Dialer func(string, string) (net.Conn, error)
// Time between sending a ping and receiving a pong. See
// https://godoc.org/github.com/rcrowley/go-metrics#Timer.
PingPongLatencyTimer metrics.Timer
// Single user facing channel to read RPCResponses from, closed only when the client is being stopped.
ResponsesCh chan types.RPCResponse
@@ -53,15 +47,18 @@ type WSClient struct {
reconnectAfter chan error // reconnect requests
readRoutineQuit chan struct{} // a way for readRoutine to close writeRoutine
// Maximum reconnect attempts (0 or greater; default: 25).
maxReconnectAttempts int
// Support both ws and wss protocols
protocol string
wg sync.WaitGroup
mtx sync.RWMutex
sentLastPingAt time.Time
reconnecting bool
// Maximum reconnect attempts (0 or greater; default: 25).
maxReconnectAttempts int
// Time allowed to write a message to the server. 0 means block until operation succeeds.
writeWait time.Duration
@@ -71,8 +68,11 @@ type WSClient struct {
// Send pings to server with this period. Must be less than readWait. If 0, no pings will be sent.
pingPeriod time.Duration
// Support both ws and wss protocols
protocol string
cmn.BaseService
// Time between sending a ping and receiving a pong. See
// https://godoc.org/github.com/rcrowley/go-metrics#Timer.
PingPongLatencyTimer metrics.Timer
}
// NewWSClient returns a new client. See the commentary on the func(*WSClient)
+6 -7
View File
@@ -3,7 +3,6 @@ package rpcclient
import (
"context"
"encoding/json"
"net"
"net/http"
"net/http/httptest"
"sync"
@@ -65,7 +64,7 @@ func TestWSClientReconnectsAfterReadFailure(t *testing.T) {
s := httptest.NewServer(h)
defer s.Close()
c := startClient(t, s.Listener.Addr())
c := startClient(t, s.Listener.Addr().String())
defer c.Stop()
wg.Add(1)
@@ -97,7 +96,7 @@ func TestWSClientReconnectsAfterWriteFailure(t *testing.T) {
h := &myHandler{}
s := httptest.NewServer(h)
c := startClient(t, s.Listener.Addr())
c := startClient(t, s.Listener.Addr().String())
defer c.Stop()
wg.Add(2)
@@ -125,7 +124,7 @@ func TestWSClientReconnectFailure(t *testing.T) {
h := &myHandler{}
s := httptest.NewServer(h)
c := startClient(t, s.Listener.Addr())
c := startClient(t, s.Listener.Addr().String())
defer c.Stop()
go func() {
@@ -174,7 +173,7 @@ func TestWSClientReconnectFailure(t *testing.T) {
func TestNotBlockingOnStop(t *testing.T) {
timeout := 2 * time.Second
s := httptest.NewServer(&myHandler{})
c := startClient(t, s.Listener.Addr())
c := startClient(t, s.Listener.Addr().String())
c.Call(context.Background(), "a", make(map[string]interface{}))
// Let the readRoutine get around to blocking
time.Sleep(time.Second)
@@ -194,8 +193,8 @@ func TestNotBlockingOnStop(t *testing.T) {
}
}
func startClient(t *testing.T, addr net.Addr) *WSClient {
c := NewWSClient(addr.String(), "/websocket")
func startClient(t *testing.T, addr string) *WSClient {
c := NewWSClient(addr, "/websocket")
err := c.Start()
require.Nil(t, err)
c.SetLogger(log.TestingLogger())
+4 -4
View File
@@ -146,7 +146,7 @@ func setup() {
time.Sleep(time.Second * 2)
}
func echoViaHTTP(cl client.HTTPClient, val string) (string, error) {
func echoViaHTTP(cl client.JSONRPCCaller, val string) (string, error) {
params := map[string]interface{}{
"arg": val,
}
@@ -157,7 +157,7 @@ func echoViaHTTP(cl client.HTTPClient, val string) (string, error) {
return result.Value, nil
}
func echoIntViaHTTP(cl client.HTTPClient, val int) (int, error) {
func echoIntViaHTTP(cl client.JSONRPCCaller, val int) (int, error) {
params := map[string]interface{}{
"arg": val,
}
@@ -168,7 +168,7 @@ func echoIntViaHTTP(cl client.HTTPClient, val int) (int, error) {
return result.Value, nil
}
func echoBytesViaHTTP(cl client.HTTPClient, bytes []byte) ([]byte, error) {
func echoBytesViaHTTP(cl client.JSONRPCCaller, bytes []byte) ([]byte, error) {
params := map[string]interface{}{
"arg": bytes,
}
@@ -179,7 +179,7 @@ func echoBytesViaHTTP(cl client.HTTPClient, bytes []byte) ([]byte, error) {
return result.Value, nil
}
func echoDataBytesViaHTTP(cl client.HTTPClient, bytes cmn.HexBytes) (cmn.HexBytes, error) {
func echoDataBytesViaHTTP(cl client.JSONRPCCaller, bytes cmn.HexBytes) (cmn.HexBytes, error) {
params := map[string]interface{}{
"arg": bytes,
}