Skip to content

Commit

Permalink
Frustrations
Browse files Browse the repository at this point in the history
  • Loading branch information
cranktakular committed Dec 12, 2024
1 parent 1f17919 commit bbde222
Show file tree
Hide file tree
Showing 8 changed files with 495 additions and 499 deletions.
54 changes: 2 additions & 52 deletions exchanges/bitget/bitget.go
Original file line number Diff line number Diff line change
Expand Up @@ -5058,56 +5058,6 @@ func (p *Params) prepareDateString(startDate, endDate time.Time, ignoreUnsetStar
return nil
}

// UnmarshalJSON unmarshals the JSON input into a UnixTimestamp type
func (t *UnixTimestamp) UnmarshalJSON(b []byte) error {
var timestampStr string
err := json.Unmarshal(b, &timestampStr)
if err != nil {
return err
}
if timestampStr == "" {
*t = UnixTimestamp(time.Time{})
return nil
}
timestamp, err := strconv.ParseInt(timestampStr, 10, 64)
if err != nil {
return err
}
*t = UnixTimestamp(time.UnixMilli(timestamp).UTC())
return nil
}

// String implements the stringer interface
func (t *UnixTimestamp) String() string {
return t.Time().String()
}

// Time returns the time.Time representation of the UnixTimestamp
func (t *UnixTimestamp) Time() time.Time {
return time.Time(*t)
}

// UnmarshalJSON unmarshals the JSON input into a UnixTimestampNumber type
func (t *UnixTimestampNumber) UnmarshalJSON(b []byte) error {
var timestampNum uint64
err := json.Unmarshal(b, &timestampNum)
if err != nil {
return err
}
*t = UnixTimestampNumber(time.UnixMilli(int64(timestampNum)).UTC())
return nil
}

// String implements the stringer interface
func (t *UnixTimestampNumber) String() string {
return t.Time().String()
}

// Time returns the time.Time representation of the UnixTimestampNumber
func (t *UnixTimestampNumber) Time() time.Time {
return time.Time(*t)
}

// UnmarshalJSON unmarshals the JSON input into a YesNoBool type
func (y *YesNoBool) UnmarshalJSON(b []byte) error {
var yn string
Expand Down Expand Up @@ -5245,7 +5195,7 @@ func (bi *Bitget) candlestickHelper(ctx context.Context, pair currency.Pair, gra
if !ok {
return nil, errTypeAssertUSDTVolume
}
data.SpotCandles[i].Timestamp = time.Time(UnixTimestamp(time.UnixMilli(timeTemp2).UTC()))
data.SpotCandles[i].Timestamp = time.Time(time.UnixMilli(timeTemp2).UTC())
data.SpotCandles[i].Open, err = strconv.ParseFloat(openTemp, 64)
if err != nil {
return nil, err
Expand Down Expand Up @@ -5275,7 +5225,7 @@ func (bi *Bitget) candlestickHelper(ctx context.Context, pair currency.Pair, gra
return nil, err
}
} else {
data.FuturesCandles[i].Timestamp = time.Time(UnixTimestamp(time.UnixMilli(timeTemp2).UTC()))
data.FuturesCandles[i].Timestamp = time.Time(time.UnixMilli(timeTemp2).UTC())
data.FuturesCandles[i].Entry, err = strconv.ParseFloat(openTemp, 64)
if err != nil {
return nil, err
Expand Down
17 changes: 12 additions & 5 deletions exchanges/bitget/bitget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3344,11 +3344,18 @@ func TestWsAuth(t *testing.T) {
time.Sleep(sharedtestvalues.WebsocketResponseDefaultTimeout)
}

func TestWsReadData(t *testing.T) {
// wsTest := testexch.MockWsInstance[Bitget](t, mockws.wsmock)
// Implement internal/testing/websocket mockws stuff after merging
// See: https://github.com/thrasher-corp/gocryptotrader/blob/master/exchanges/kraken/kraken_test.go#L1169
}
// func TestWsReadData(t *testing.T) {
// mock := func(tb testing.TB, msg []byte, w *websocket.Conn) error {
// tb.Helper()
// return w.WriteMessage(websocket.TextMessage, msg)
// }
// wsTest := testexch.MockWsInstance[Bitget](t, mockws.CurryWsMockUpgrader(t, mock))
// wsTest.Websocket.Enable()
// err := wsTest.Subscribe(defaultSubscriptions)
// require.NoError(t, err)
// // Implement internal/testing/websocket mockws stuff after merging
// // See: https://github.com/thrasher-corp/gocryptotrader/blob/master/exchanges/kraken/kraken_test.go#L1169
// }

func TestWsHandleData(t *testing.T) {
ch := make(chan struct{})
Expand Down
Loading

0 comments on commit bbde222

Please sign in to comment.