mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-31 23:16:54 +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:
@@ -37,8 +37,8 @@ type Kraken struct {
|
||||
wsRequestMtx sync.Mutex
|
||||
}
|
||||
|
||||
// GetServerTime returns current server time
|
||||
func (k *Kraken) GetServerTime(ctx context.Context) (TimeResponse, error) {
|
||||
// GetCurrentServerTime returns current server time
|
||||
func (k *Kraken) GetCurrentServerTime(ctx context.Context) (TimeResponse, error) {
|
||||
path := fmt.Sprintf("/%s/public/%s", krakenAPIVersion, krakenServerTime)
|
||||
|
||||
var response struct {
|
||||
|
||||
@@ -75,11 +75,23 @@ func TestStart(t *testing.T) {
|
||||
testWg.Wait()
|
||||
}
|
||||
|
||||
func TestGetServerTime(t *testing.T) {
|
||||
func TestGetCurrentServerTime(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := k.GetServerTime(context.Background())
|
||||
_, err := k.GetCurrentServerTime(context.Background())
|
||||
if err != nil {
|
||||
t.Error("GetServerTime() error", err)
|
||||
t.Error("GetCurrentServerTime() error", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWrapperGetServerTime(t *testing.T) {
|
||||
t.Parallel()
|
||||
st, err := k.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")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1565,3 +1565,12 @@ func (k *Kraken) GetAvailableTransferChains(ctx context.Context, cryptocurrency
|
||||
}
|
||||
return availableChains, nil
|
||||
}
|
||||
|
||||
// GetServerTime returns the current exchange server time.
|
||||
func (k *Kraken) GetServerTime(ctx context.Context, _ asset.Item) (time.Time, error) {
|
||||
st, err := k.GetCurrentServerTime(ctx)
|
||||
if err != nil {
|
||||
return time.Time{}, err
|
||||
}
|
||||
return time.Parse("Mon, 02 Jan 06 15:04:05 -0700", st.Rfc1123)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user