chore: Format and fix lints (#9336)

* make format

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Fix linting directives

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* make mockery

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Appease CI linter

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Appease CI linter

Signed-off-by: Thane Thomson <connect@thanethomson.com>

Signed-off-by: Thane Thomson <connect@thanethomson.com>
This commit is contained in:
Thane Thomson
2022-08-30 12:28:46 -04:00
committed by GitHub
parent 7b40167f58
commit cceea4de22
87 changed files with 402 additions and 384 deletions

View File

@@ -39,24 +39,24 @@ the example for more details.
Example:
c, err := New("http://192.168.1.10:26657", "/websocket")
if err != nil {
// handle error
}
c, err := New("http://192.168.1.10:26657", "/websocket")
if err != nil {
// handle error
}
// call Start/Stop if you're subscribing to events
err = c.Start()
if err != nil {
// handle error
}
defer c.Stop()
// call Start/Stop if you're subscribing to events
err = c.Start()
if err != nil {
// handle error
}
defer c.Stop()
res, err := c.Status()
if err != nil {
// handle error
}
res, err := c.Status()
if err != nil {
// handle error
}
// handle result
// handle result
*/
type HTTP struct {
remote string

View File

@@ -47,7 +47,6 @@ var _ client.Client = Client{}
// Call is used by recorders to save a call and response.
// It can also be used to configure mock responses.
//
type Call struct {
Name string
Args interface{}

View File

@@ -69,7 +69,7 @@ type peers interface {
Peers() p2p.IPeerSet
}
//----------------------------------------------
// ----------------------------------------------
// Environment contains objects and interfaces used by the RPC. It is expected
// to be setup once during startup.
type Environment struct {

View File

@@ -30,7 +30,7 @@ const (
// the remote server.
//
// WSClient is safe for concurrent use by multiple goroutines.
type WSClient struct { // nolint: maligned
type WSClient struct { //nolint: maligned
conn *websocket.Conn
Address string // IP:PORT or /path/to/socket
@@ -265,7 +265,7 @@ func (c *WSClient) dial() error {
Proxy: http.ProxyFromEnvironment,
}
rHeader := http.Header{}
conn, _, err := dialer.Dial(c.protocol+"://"+c.Address+c.Endpoint, rHeader) // nolint:bodyclose
conn, _, err := dialer.Dial(c.protocol+"://"+c.Address+c.Endpoint, rHeader) //nolint:bodyclose
if err != nil {
return err
}

View File

@@ -72,7 +72,7 @@ func TestWSClientReconnectsAfterReadFailure(t *testing.T) {
defer s.Close()
c := startClient(t, "//"+s.Listener.Addr().String())
defer c.Stop() // nolint:errcheck // ignore for tests
defer c.Stop() //nolint:errcheck // ignore for tests
wg.Add(1)
go callWgDoneOnResult(t, c, &wg)
@@ -104,7 +104,7 @@ func TestWSClientReconnectsAfterWriteFailure(t *testing.T) {
s := httptest.NewServer(h)
c := startClient(t, "//"+s.Listener.Addr().String())
defer c.Stop() // nolint:errcheck // ignore for tests
defer c.Stop() //nolint:errcheck // ignore for tests
wg.Add(2)
go callWgDoneOnResult(t, c, &wg)
@@ -132,7 +132,7 @@ func TestWSClientReconnectFailure(t *testing.T) {
s := httptest.NewServer(h)
c := startClient(t, "//"+s.Listener.Addr().String())
defer c.Stop() // nolint:errcheck // ignore for tests
defer c.Stop() //nolint:errcheck // ignore for tests
go func() {
for {
@@ -181,7 +181,7 @@ func TestNotBlockingOnStop(t *testing.T) {
timeout := 2 * time.Second
s := httptest.NewServer(&myHandler{})
c := startClient(t, "//"+s.Listener.Addr().String())
c.Call(context.Background(), "a", make(map[string]interface{})) // nolint:errcheck // ignore for tests
c.Call(context.Background(), "a", make(map[string]interface{})) //nolint:errcheck // ignore for tests
// Let the readRoutine get around to blocking
time.Sleep(time.Second)
passCh := make(chan struct{})

View File

@@ -176,8 +176,9 @@ func arrayParamsToArgs(
// array.
//
// Example:
// rpcFunc.args = [rpctypes.Context string]
// rpcFunc.argNames = ["arg"]
//
// rpcFunc.args = [rpctypes.Context string]
// rpcFunc.argNames = ["arg"]
func jsonParamsToArgs(rpcFunc *RPCFunc, raw []byte) ([]reflect.Value, error) {
const argsOffset = 1
@@ -237,5 +238,5 @@ func writeListOfEndpoints(w http.ResponseWriter, r *http.Request, funcMap map[st
buf.WriteString("</body></html>")
w.Header().Set("Content-Type", "text/html")
w.WriteHeader(200)
w.Write(buf.Bytes()) // nolint: errcheck
w.Write(buf.Bytes()) //nolint: errcheck
}

View File

@@ -215,15 +215,17 @@ func (resp RPCResponse) String() string {
}
// From the JSON-RPC 2.0 spec:
//
// If there was an error in detecting the id in the Request object (e.g. Parse
// error/Invalid Request), it MUST be Null.
// error/Invalid Request), it MUST be Null.
func RPCParseError(err error) RPCResponse {
return NewRPCErrorResponse(nil, -32700, "Parse error. Invalid JSON", err.Error())
}
// From the JSON-RPC 2.0 spec:
//
// If there was an error in detecting the id in the Request object (e.g. Parse
// error/Invalid Request), it MUST be Null.
// error/Invalid Request), it MUST be Null.
func RPCInvalidRequestError(id jsonrpcid, err error) RPCResponse {
return NewRPCErrorResponse(id, -32600, "Invalid Request", err.Error())
}
@@ -276,9 +278,12 @@ type Context struct {
// RemoteAddr returns the remote address (usually a string "IP:port").
// If neither HTTPReq nor WSConn is set, an empty string is returned.
// HTTP:
// http.Request#RemoteAddr
//
// http.Request#RemoteAddr
//
// WS:
// result of GetRemoteAddr
//
// result of GetRemoteAddr
func (ctx *Context) RemoteAddr() string {
if ctx.HTTPReq != nil {
return ctx.HTTPReq.RemoteAddr
@@ -291,10 +296,13 @@ func (ctx *Context) RemoteAddr() string {
// Context returns the request's context.
// The returned context is always non-nil; it defaults to the background context.
// HTTP:
// The context is canceled when the client's connection closes, the request
// is canceled (with HTTP/2), or when the ServeHTTP method returns.
//
// The context is canceled when the client's connection closes, the request
// is canceled (with HTTP/2), or when the ServeHTTP method returns.
//
// WS:
// The context is canceled when the client's connections closes.
//
// The context is canceled when the client's connections closes.
func (ctx *Context) Context() context.Context {
if ctx.HTTPReq != nil {
return ctx.HTTPReq.Context()
@@ -307,7 +315,6 @@ func (ctx *Context) Context() context.Context {
//----------------------------------------
// SOCKETS
//
// Determine if its a unix or tcp socket.
// If tcp, must specify the port; `0.0.0.0` will return incorrectly as "unix" since there's no port
// TODO: deprecate