github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/tests/integration/v2/api_test.go (about) 1 package tests 2 3 /* 4 import ( 5 "context" 6 "github.com/bitfinexcom/bitfinex-api-go/v2/websocket" 7 "testing" 8 "time" 9 ) 10 11 // the following test is used to run the API against 12 13 func TestAPI(t *testing.T) { 14 // create transport & nonce mocks 15 16 // create client 17 params := websocket.NewDefaultParameters() 18 params.URL = "wss://dev-prdn.bitfinex.com:2997/ws/2" 19 ws := websocket.NewWithParams(params) //.Credentials("U83q9jkML2GVj1fVxFJOAXQeDGaXIzeZ6PwNPQLEXt4", "77SWIRggvw0rCOJUgk9GVcxbldjTxOJP5WLCjWBFIVc") 20 21 // setup listener 22 listener := newListener() 23 listener.run(ws.Listen()) 24 25 // set ws options 26 //ws.SetReadTimeout(time.Second * 2) 27 ws.Connect() 28 defer ws.Close() 29 30 // begin test 31 //ev, err := listener.nextAuthEvent() 32 //if err != nil { 33 // t.Fatal(err) 34 //} 35 //assert(t, &websocket.AuthEvent{Event: "auth", Status: "OK"}, ev) 36 37 38 tradeSubID, err := ws.SubscribeTrades(context.Background(), "tBTCUSD") 39 if err != nil { 40 t.Fatal(err) 41 } 42 t.Logf("trade sub ID: %s", tradeSubID) 43 44 //bookSubID, err := ws.SubscribeBook(context.Background(), "tBTCUSD", websocket.Precision0, websocket.FrequencyRealtime) 45 //t.Logf("book sub ID: %s", bookSubID) 46 47 time.Sleep(time.Second * 15) 48 } 49 */