mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-29 15:10:37 +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:
@@ -273,10 +273,9 @@ func (c *CoinbasePro) GetCurrencies(ctx context.Context) ([]Currency, error) {
|
||||
return currencies, c.SendHTTPRequest(ctx, exchange.RestSpot, coinbaseproCurrencies, ¤cies)
|
||||
}
|
||||
|
||||
// GetServerTime returns the API server time
|
||||
func (c *CoinbasePro) GetServerTime(ctx context.Context) (ServerTime, error) {
|
||||
// GetCurrentServerTime returns the API server time
|
||||
func (c *CoinbasePro) GetCurrentServerTime(ctx context.Context) (ServerTime, error) {
|
||||
serverTime := ServerTime{}
|
||||
|
||||
return serverTime, c.SendHTTPRequest(ctx, exchange.RestSpot, coinbaseproTime, &serverTime)
|
||||
}
|
||||
|
||||
|
||||
@@ -144,13 +144,25 @@ func TestGetCurrencies(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetServerTime(t *testing.T) {
|
||||
_, err := c.GetServerTime(context.Background())
|
||||
func TestGetCurrentServerTime(t *testing.T) {
|
||||
_, err := c.GetCurrentServerTime(context.Background())
|
||||
if err != nil {
|
||||
t.Error("GetServerTime() error", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWrapperGetServerTime(t *testing.T) {
|
||||
t.Parallel()
|
||||
st, err := c.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 TestAuthRequests(t *testing.T) {
|
||||
if !areTestAPIKeysSet() {
|
||||
t.Skip("API keys not set, skipping test")
|
||||
|
||||
@@ -1019,3 +1019,12 @@ func (c *CoinbasePro) ValidateCredentials(ctx context.Context, assetType asset.I
|
||||
_, err := c.UpdateAccountInfo(ctx, assetType)
|
||||
return c.CheckTransientError(err)
|
||||
}
|
||||
|
||||
// GetServerTime returns the current exchange server time.
|
||||
func (c *CoinbasePro) GetServerTime(ctx context.Context, _ asset.Item) (time.Time, error) {
|
||||
st, err := c.GetCurrentServerTime(ctx)
|
||||
if err != nil {
|
||||
return time.Time{}, err
|
||||
}
|
||||
return st.ISO, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user