mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
Merge pull request #1476 from c9s/edwin/okx/add-streaming-test
CHORE: [okex] add stream test for book
This commit is contained in:
commit
6e03626b36
51
pkg/exchange/okex/stream_test.go
Normal file
51
pkg/exchange/okex/stream_test.go
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
package okex
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
|
"github.com/c9s/bbgo/pkg/testutil"
|
||||||
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func getTestClientOrSkip(t *testing.T) *Stream {
|
||||||
|
if b, _ := strconv.ParseBool(os.Getenv("CI")); b {
|
||||||
|
t.Skip("skip test for CI")
|
||||||
|
}
|
||||||
|
|
||||||
|
key, secret, passphrase, ok := testutil.IntegrationTestWithPassphraseConfigured(t, "OKEX")
|
||||||
|
if !ok {
|
||||||
|
t.Skip("OKEX_* env vars are not configured")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
exchange := New(key, secret, passphrase)
|
||||||
|
return NewStream(exchange.client)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestStream(t *testing.T) {
|
||||||
|
t.Skip()
|
||||||
|
s := getTestClientOrSkip(t)
|
||||||
|
|
||||||
|
t.Run("book test", func(t *testing.T) {
|
||||||
|
s.Subscribe(types.BookChannel, "BTCUSDT", types.SubscribeOptions{
|
||||||
|
Depth: types.DepthLevel50,
|
||||||
|
})
|
||||||
|
s.SetPublicOnly()
|
||||||
|
err := s.Connect(context.Background())
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
s.OnBookSnapshot(func(book types.SliceOrderBook) {
|
||||||
|
t.Log("got snapshot", book)
|
||||||
|
})
|
||||||
|
s.OnBookUpdate(func(book types.SliceOrderBook) {
|
||||||
|
t.Log("got update", book)
|
||||||
|
})
|
||||||
|
c := make(chan struct{})
|
||||||
|
<-c
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user