MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / setupWebsocketClient

Function setupWebsocketClient

api/service_test.go:134–164  ·  view source on GitHub ↗
(addr string)

Source from the content-addressed store, hash-verified

132}
133
134func setupWebsocketClient(addr string) (client *jsonrpc2.Conn, err error) {
135 var dial = func(ctx context.Context, addr string) (client *jsonrpc2.Conn, err error) {
136 conn, _, err := websocket.DefaultDialer.DialContext(
137 context.Background(),
138 addr,
139 nil,
140 )
141 if err != nil {
142 return nil, err
143 }
144
145 var connOpts []jsonrpc2.ConnOpt
146 return jsonrpc2.NewConn(
147 context.Background(),
148 wsstream.NewObjectStream(conn),
149 nil,
150 connOpts...,
151 ), nil
152 }
153
154 for i := 0; i < 3; i++ {
155 ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
156 defer cancel()
157 client, err = dial(ctx, addr)
158 if err == nil {
159 break
160 }
161 }
162
163 return client, err
164}
165
166type bpGetBlockListTestCase struct {
167 Since int

Callers 1

TestJSONRPCServiceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected