exchanges: Initial context propagation (#744)

* gct: phase one context awareness pass

* exchanges: context propagation pass

* common/requester: force context requirement

* gctcli/exchanges: linter fix

* rpcserver: fix test using dummy rpc server

* backtester: fix comments

* grpc: add correct cancel and timeout for commands

* rpcserver_test: add comment on dummy server

* common: deprecated SendHTTPGetRequest

* linter: fix

* linter: turn on no context check

* apichecker: fix context linter issue

* binance: use param context

* common: remove checks as this gets executed before main

* common: change mutex to RW as clients can be used by multiple go routines.

* common: remove init and JIT default client. Unexport global variables and add protection.

* common: Add comments

* bithumb: after dinner mints fix
This commit is contained in:
Ryan O'Hara-Reid
2021-09-11 13:52:07 +10:00
committed by GitHub
parent 72516f7268
commit d636049fb2
168 changed files with 8085 additions and 6996 deletions

View File

@@ -2,6 +2,7 @@ package mock
import (
"bytes"
"context"
"encoding/json"
"io/ioutil"
"net/http"
@@ -57,39 +58,45 @@ func TestNewVCRServer(t *testing.T) {
t.Error("NewVCRServer error", err)
}
common.HTTPClient = client // Set common package global HTTP Client
err = common.SetHTTPClient(client) // Set common package global HTTP Client
if err != nil {
t.Fatal(err)
}
_, err = common.SendHTTPRequest(http.MethodGet,
_, err = common.SendHTTPRequest(context.Background(),
http.MethodGet,
"http://localhost:300/somethingElse?"+queryString,
nil,
bytes.NewBufferString(""))
bytes.NewBufferString(""), true)
if err == nil {
t.Error("Sending http request expected an error")
}
// Expected good outcome
r, err := common.SendHTTPRequest(http.MethodGet,
r, err := common.SendHTTPRequest(context.Background(),
http.MethodGet,
deets,
nil,
bytes.NewBufferString(""))
bytes.NewBufferString(""), true)
if err != nil {
t.Error("Sending http request error", err)
}
if !strings.Contains(r, "404 page not found") {
if !strings.Contains(string(r), "404 page not found") {
t.Error("Was not expecting any value returned:", r)
}
r, err = common.SendHTTPRequest(http.MethodGet,
r, err = common.SendHTTPRequest(context.Background(),
http.MethodGet,
deets+"/test?"+queryString,
nil,
bytes.NewBufferString(""))
bytes.NewBufferString(""), true)
if err != nil {
t.Error("Sending http request error", err)
}
var res responsePayload
err = json.Unmarshal([]byte(r), &res)
err = json.Unmarshal(r, &res)
if err != nil {
t.Error("unmarshal error", err)
}