diff --git a/exchanges/bitstamp/bitstamp_test.go b/exchanges/bitstamp/bitstamp_test.go index 6234d53c..bbcb64fc 100644 --- a/exchanges/bitstamp/bitstamp_test.go +++ b/exchanges/bitstamp/bitstamp_test.go @@ -388,15 +388,23 @@ func TestGetOrderStatus(t *testing.T) { func TestGetWithdrawalRequests(t *testing.T) { t.Parallel() - - _, err := b.GetWithdrawalRequests(context.Background(), 0) - switch { - case sharedtestvalues.AreAPICredentialsSet(b) && err != nil && !mockTests: - t.Error("GetWithdrawalRequests() error", err) - case !sharedtestvalues.AreAPICredentialsSet(b) && err == nil && !mockTests: - t.Error("Expecting an error when no keys are set") - case mockTests && err != nil: - t.Error("GetWithdrawalRequests() error", err) + if !mockTests { + sharedtestvalues.SkipTestIfCredentialsUnset(t, b) + } + r, err := b.GetWithdrawalRequests(context.Background(), 1) + assert.NoError(t, err, "GetWithdrawalRequests should not error") + if mockTests { + assert.NotEmpty(t, r, "GetWithdrawalRequests should return a withdrawal request") + for _, req := range r { + assert.Equal(t, int64(1), req.OrderID, "OrderId should match") + assert.Equal(t, "aMDHooGmAkyrsaQiKhAORhSNTmoRzxqWIO", req.Address, "Address should match") + assert.Equal(t, "2022-01-31 16:07:32", req.Date, "Date should match") + assert.Equal(t, currency.BTC, req.Currency, "Currency should match") + assert.Equal(t, 0.00006000, req.Amount, "Amount should match") + assert.Equal(t, "NsOeFbQhRnpGzNIThWGBTkQwRJqTNOGPVhYavrVyMfkAyMUmIlUpFIwGTzSvpeOP", req.TransactionID, "TransactionID should match") + assert.Equal(t, int64(2), req.Status, "Status should match") + assert.Equal(t, int64(0), req.Type, "Type should match") + } } } diff --git a/exchanges/bitstamp/bitstamp_types.go b/exchanges/bitstamp/bitstamp_types.go index 723c0394..924a1931 100644 --- a/exchanges/bitstamp/bitstamp_types.go +++ b/exchanges/bitstamp/bitstamp_types.go @@ -2,7 +2,6 @@ package bitstamp import ( "errors" - "time" "github.com/thrasher-corp/gocryptotrader/currency" ) @@ -156,7 +155,7 @@ type DepositAddress struct { // WithdrawalRequests holds request information on withdrawals type WithdrawalRequests struct { OrderID int64 `json:"id"` - Date time.Time `json:"datetime"` + Date string `json:"datetime"` Type int64 `json:"type"` Amount float64 `json:"amount,string"` Status int64 `json:"status"` diff --git a/exchanges/bitstamp/bitstamp_wrapper.go b/exchanges/bitstamp/bitstamp_wrapper.go index 8e0ad553..4f6fe92a 100644 --- a/exchanges/bitstamp/bitstamp_wrapper.go +++ b/exchanges/bitstamp/bitstamp_wrapper.go @@ -540,10 +540,15 @@ func (b *Bitstamp) GetWithdrawalsHistory(ctx context.Context, c currency.Code, _ } resp := make([]exchange.WithdrawalHistory, 0, len(withdrawals)) for i := range withdrawals { + var tm time.Time + tm, err = parseTime(withdrawals[i].Date) + if err != nil { + return nil, fmt.Errorf("getWithdrawalsHistory unable to parse Date field: %w", err) + } if c.IsEmpty() || c.Equal(withdrawals[i].Currency) { resp = append(resp, exchange.WithdrawalHistory{ Status: strconv.FormatInt(withdrawals[i].Status, 10), - Timestamp: withdrawals[i].Date, + Timestamp: tm, Currency: withdrawals[i].Currency.String(), Amount: withdrawals[i].Amount, TransferType: strconv.FormatInt(withdrawals[i].Type, 10), diff --git a/testdata/http_mock/bitstamp/bitstamp.json b/testdata/http_mock/bitstamp/bitstamp.json index 86f8879f..a8bc4dae 100644 --- a/testdata/http_mock/bitstamp/bitstamp.json +++ b/testdata/http_mock/bitstamp/bitstamp.json @@ -68270,9 +68270,20 @@ "/api/withdrawal_requests/": { "POST": [ { - "data": [], + "data": [{ + "address": "aMDHooGmAkyrsaQiKhAORhSNTmoRzxqWIO", + "amount": "0.00006000", + "currency": "BTC", + "datetime": "2022-01-31 16:07:32", + "id": 1, + "network": "bitcoin", + "status": 2, + "transaction_id": "NsOeFbQhRnpGzNIThWGBTkQwRJqTNOGPVhYavrVyMfkAyMUmIlUpFIwGTzSvpeOP", + "txid": 1, + "type": 0 + }], "queryString": "", - "bodyParams": "key=\u0026nonce=1560480184558170717\u0026signature=5CE4CEFAA663FA03DE0005741683D2AE77D9ACD75F4644A2A1E9030E596D4E04", + "bodyParams": "key=&nonce=1701424773861988000&signature=63D3A30E29FF85C814715111F8AC138B0D658C01D45A2EDDCE1E0F09B354DA88&timedelta=1", "headers": { "Content-Type": [ "application/x-www-form-urlencoded"