2021-04-28 11:20:55 +00:00
|
|
|
package binance
|
|
|
|
|
|
|
|
import (
|
2024-03-12 06:57:22 +00:00
|
|
|
"context"
|
2024-03-12 08:48:55 +00:00
|
|
|
"os"
|
2021-04-28 11:20:55 +00:00
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Test_newClientOrderID(t *testing.T) {
|
|
|
|
cID := newSpotClientOrderID("")
|
|
|
|
assert.Len(t, cID, 32)
|
2022-03-18 08:17:04 +00:00
|
|
|
strings.HasPrefix(cID, "x-"+spotBrokerID)
|
2021-04-28 11:20:55 +00:00
|
|
|
|
|
|
|
cID = newSpotClientOrderID("myid1")
|
2022-03-18 08:17:04 +00:00
|
|
|
assert.Equal(t, cID, "x-"+spotBrokerID+"myid1")
|
2021-04-28 11:20:55 +00:00
|
|
|
}
|
2024-03-12 06:57:22 +00:00
|
|
|
|
|
|
|
func Test_new(t *testing.T) {
|
|
|
|
ex := New("", "")
|
|
|
|
assert.NotEmpty(t, ex)
|
|
|
|
ctx := context.Background()
|
|
|
|
ticker, err := ex.QueryTicker(ctx, "btcusdt")
|
2024-03-12 08:48:55 +00:00
|
|
|
if len(os.Getenv("GITHUB_CI")) > 0 {
|
|
|
|
// Github action runs in the US, and therefore binance api is not accessible
|
|
|
|
assert.Empty(t, ticker)
|
|
|
|
assert.Error(t, err)
|
|
|
|
} else {
|
|
|
|
assert.NotEmpty(t, ticker)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
2024-03-12 06:57:22 +00:00
|
|
|
}
|