(addr string)
| 132 | } |
| 133 | |
| 134 | func 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 | |
| 166 | type bpGetBlockListTestCase struct { |
| 167 | Since int |
no outgoing calls
no test coverage detected