mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-05 23:16:53 +00:00
exchange/wrapper: add GetServerTime() for exchange analytics (#938)
* exchange/wrapper: add GetServerTime() for exchange analytics * binance: fix linter issue * glorious: nits * glorious: nits rides again * thrasher: nits implement huobi * thrasher: nits add to exchange_wrapper_issues cmd
This commit is contained in:
@@ -270,8 +270,8 @@ func (b *BTCMarkets) GetMultipleOrderbooks(ctx context.Context, marketIDs []stri
|
||||
return orderbooks, nil
|
||||
}
|
||||
|
||||
// GetServerTime gets time from btcmarkets
|
||||
func (b *BTCMarkets) GetServerTime(ctx context.Context) (time.Time, error) {
|
||||
// GetCurrentServerTime gets time from btcmarkets
|
||||
func (b *BTCMarkets) GetCurrentServerTime(ctx context.Context) (time.Time, error) {
|
||||
var resp TimeResp
|
||||
return resp.Time, b.SendHTTPRequest(ctx, btcMarketsAPIURL+btcMarketsAPIVersion+btcMarketsGetTime,
|
||||
&resp)
|
||||
|
||||
@@ -142,14 +142,26 @@ func TestGetMultipleOrderbooks(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetServerTime(t *testing.T) {
|
||||
func TestGetCurrentServerTime(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := b.GetServerTime(context.Background())
|
||||
_, err := b.GetCurrentServerTime(context.Background())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWrapperGetServerTime(t *testing.T) {
|
||||
t.Parallel()
|
||||
st, err := b.GetServerTime(context.Background(), asset.Spot)
|
||||
if !errors.Is(err, nil) {
|
||||
t.Fatalf("received: '%v' but expected: '%v'", err, nil)
|
||||
}
|
||||
|
||||
if st.IsZero() {
|
||||
t.Fatal("expected a time")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetAccountBalance(t *testing.T) {
|
||||
t.Parallel()
|
||||
if !areTestAPIKeysSet() {
|
||||
|
||||
@@ -1086,3 +1086,8 @@ func (b *BTCMarkets) GetHistoricCandlesExtended(ctx context.Context, p currency.
|
||||
ret.SortCandlesByTimestamp(false)
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// GetServerTime returns the current exchange server time.
|
||||
func (b *BTCMarkets) GetServerTime(ctx context.Context, _ asset.Item) (time.Time, error) {
|
||||
return b.GetCurrentServerTime(ctx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user