mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
removed unnecessary channel / goroutine from ws and http tests
This commit is contained in:
parent
19f658d2ad
commit
eebca1d113
1 changed files with 6 additions and 13 deletions
|
|
@ -614,11 +614,8 @@ func TestWebsocketHTTPOnSamePort_WebsocketRequest(t *testing.T) {
|
||||||
wsReq.Header.Set("Sec-WebSocket-Version", "13")
|
wsReq.Header.Set("Sec-WebSocket-Version", "13")
|
||||||
wsReq.Header.Set("Sec-Websocket-Key", "SGVsbG8sIHdvcmxkIQ==")
|
wsReq.Header.Set("Sec-Websocket-Key", "SGVsbG8sIHdvcmxkIQ==")
|
||||||
|
|
||||||
wsResponses := make(chan *http.Response)
|
resp := doHTTPRequest(t, wsReq)
|
||||||
go doHTTPRequest(t, wsResponses, wsReq)
|
assert.Equal(t, "websocket", resp.Header.Get("Upgrade"))
|
||||||
wsResponse := <-wsResponses
|
|
||||||
|
|
||||||
assert.Equal(t, "websocket", wsResponse.Header.Get("Upgrade"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWebsocketHTTPOnSamePort_HTTPRequest(t *testing.T) {
|
func TestWebsocketHTTPOnSamePort_HTTPRequest(t *testing.T) {
|
||||||
|
|
@ -631,11 +628,8 @@ func TestWebsocketHTTPOnSamePort_HTTPRequest(t *testing.T) {
|
||||||
}
|
}
|
||||||
httpReq.Header.Set("Accept-Encoding", "gzip")
|
httpReq.Header.Set("Accept-Encoding", "gzip")
|
||||||
|
|
||||||
httpResponses := make(chan *http.Response)
|
resp := doHTTPRequest(t, httpReq)
|
||||||
go doHTTPRequest(t, httpResponses, httpReq)
|
assert.Equal(t, "gzip", resp.Header.Get("Content-Encoding"))
|
||||||
httpResponse := <-httpResponses
|
|
||||||
|
|
||||||
assert.Equal(t, "gzip", httpResponse.Header.Get("Content-Encoding"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func startHTTP(t *testing.T) *Node {
|
func startHTTP(t *testing.T) *Node {
|
||||||
|
|
@ -653,12 +647,11 @@ func startHTTP(t *testing.T) *Node {
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
|
||||||
func doHTTPRequest(t *testing.T, responses chan *http.Response, req *http.Request) {
|
func doHTTPRequest(t *testing.T, req *http.Request) *http.Response {
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("could not issue a GET request to the given endpoint", err)
|
t.Error("could not issue a GET request to the given endpoint", err)
|
||||||
}
|
}
|
||||||
responses <- resp
|
return resp
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue