Files
gocryptotrader/exchanges/kucoin/kucoin_ratelimit_test.go
Samuael A. d94b8af3e1 exchanges: Kucoin Update (#1438)
* types and orderbook handling fix

* Minor types and endpoints update

* Minor fixes on Kucoin

* Add benchmarking test

* Unit tests update and minor endpoints update

* Adding updates and newly added endpoints

* Add and correct funding, withdrawal, and deposit endpoints

* linter and codespell fix

* Adding and correcting spot trading endpoints

* Completed Spot HF endpoints

* Minor fix

* Added OCO and Margin HF trade and other endpoints

* Adding missing endpoints

* Updating Isolated margin, margin v3, and v3market lending endpoints

* minor codespell fix

* Completed adding and fixing futures endpoints

* wrapper update and fix unit tests

* Updating endpoint ratelimits

* Complete ratelimiter setup and endpoint functions update

* Unit test configuration and update

* fix linter issue

* Added a ratelimiter test and heavy update on unit tests

* Adding websocket update based on ChangeLog

* Added newly added Earn General, Kucoin Earn and Staking endpoints

* Added VIP lending endpoints

* Minor linter and endpoints fix

* Added unit tests, publicised functions, and minor updates

* Update on wrapper funcs, unit tests, and other methods

* Enexport exchange specific websocket methods

* remove deprecated topic

* Update wrapper based on Type, add and fix unit tests

* Added a margin configuration endpoint and unit test

* Update methods, types, and unit tests

* Update error declaration and handling unit tests

* Update method parameters and error handling

* Updating unit tests and error handling

* Update methods arguments, added and update unit tests

* Fix unit tests and wrapper methods

* Resolving unit test issues and fix faulty endpoints

* Fix on unit tests and working on passphrase errors

* Minor fixed on websocket and endpoint url

* comment and wrapper filters issue fix

* Unit tests and other minor updates

* Update wrapper functions, endpoint methods, and unit tests

* change require to change on two unit tests

* Update unit tests, types, and endpoints

* Refine and update wrapper tempo for minor adjustments

* Remove code that enabled logging

* Update wrapper functions, missing endpoints, response and parameter values, and unit tests

* removed High-frequency orders from wrapper functions, and updated unit tests and types

* Added missing fields and minor update on wrapper

* Update types

* Update tests and websocket channels

* Update unit tests and methods error returns
2024-09-13 19:52:39 +10:00

202 lines
14 KiB
Go

package kucoin
import (
"context"
"net/http"
"testing"
"github.com/stretchr/testify/require"
"github.com/thrasher-corp/gocryptotrader/exchanges/request"
)
func TestRateLimit_LimitStatic(t *testing.T) {
t.Parallel()
testTable := map[string]request.EndpointLimit{
"all Account": allAccountEPL,
"account Detail": accountDetailEPL,
"account Ledgers": accountLedgersEPL,
"hf Account Ledgers": hfAccountLedgersEPL,
"hf Account Ledgers Margin": hfAccountLedgersMarginEPL,
"futures Account Ledgers": futuresAccountLedgersEPL,
"sub Account Info V1": subAccountInfoV1EPL,
"all Sub Accounts Info V2": allSubAccountsInfoV2EPL,
"create SubUser": createSubUserEPL,
"sub Accounts": subAccountsEPL,
"sub Account Balances": subAccountBalancesEPL,
"all SubAccount Balances V2": allSubAccountBalancesV2EPL,
"sub Account Spot API List": subAccountSpotAPIListEPL,
"create Spot API For Sub Account": createSpotAPIForSubAccountEPL,
"modify Sub Account Spot API": modifySubAccountSpotAPIEPL,
"delete Sub Account Spot API": deleteSubAccountSpotAPIEPL,
"margin Account Detail": marginAccountDetailEPL,
"cross Margin Accounts Detail": crossMarginAccountsDetailEPL,
"isolated Margin Account Detail": isolatedMarginAccountDetailEPL,
"futures Accounts Detail": futuresAccountsDetailEPL,
"all Futures Sub Account Balances": allFuturesSubAccountBalancesEPL,
"create Deposit Address": createDepositAddressEPL,
"deposit Addresses V2": depositAddressesV2EPL,
"deposit Addresses V1": depositAddressesV1EPL,
"deposit List": depositListEPL,
"historic Deposit List": historicDepositListEPL,
"withdrawal List": withdrawalListEPL,
"retrieve V1 Historical Withdrawal List": retrieveV1HistoricalWithdrawalListEPL,
"withdrawal Quota": withdrawalQuotaEPL,
"apply Withdrawal": applyWithdrawalEPL,
"cancel Withdrawals": cancelWithdrawalsEPL,
"get Transferables": getTransferablesEPL,
"flexi Transfer": flexiTransferEPL,
"master Sub User Transfer": masterSubUserTransferEPL,
"inner Transfer": innerTransferEPL,
"to Main Or TradeAccount": toMainOrTradeAccountEPL,
"to Futures Account": toFuturesAccountEPL,
"futures Transfer Out Request Records": futuresTransferOutRequestRecordsEPL,
"basic Fees": basicFeesEPL,
"trade Fees": tradeFeesEPL,
"spot Currencies V3": spotCurrenciesV3EPL,
"spot Currency Detail": spotCurrencyDetailEPL,
"symbols": symbolsEPL,
"tickers": tickersEPL,
"all Tickers": allTickersEPL,
"statistics 24Hr": statistics24HrEPL,
"market List": marketListEPL,
"part Orderbook 20": partOrderbook20EPL,
"part Orderbook 100": partOrderbook100EPL,
"full Orderbook": fullOrderbookEPL,
"trade History": tradeHistoryEPL,
"klines": klinesEPL,
"fiat Price": fiatPriceEPL,
"current Server Time": currentServerTimeEPL,
"service Status": serviceStatusEPL,
"hf Place Order": hfPlaceOrderEPL,
"hf Sync Place Order": hfSyncPlaceOrderEPL,
"hf Multiple Orders": hfMultipleOrdersEPL,
"hf Sync Place Multiple HF Orders": hfSyncPlaceMultipleHFOrdersEPL,
"hf Modify Order": hfModifyOrderEPL,
"cancel HF Order": cancelHFOrderEPL,
"hf Sync Cancel Order": hfSyncCancelOrderEPL,
"hf Cancel Order By Client OrderID": hfCancelOrderByClientOrderIDEPL,
"cancel Specified Number HF Orders By OrderID": cancelSpecifiedNumberHFOrdersByOrderIDEPL,
"hf Cancel All Orders By Symbol": hfCancelAllOrdersBySymbolEPL,
"hf Cancel All Orders": hfCancelAllOrdersEPL,
"hf Get All Active Orders": hfGetAllActiveOrdersEPL,
"hf Symbols With Active Orders": hfSymbolsWithActiveOrdersEPL,
"hf Completed Order List": hfCompletedOrderListEPL,
"hf Order Detail By OrderID": hfOrderDetailByOrderIDEPL,
"auto Cancel HF Order Setting": autoCancelHFOrderSettingEPL,
"auto Cancel HF Order Setting Query": autoCancelHFOrderSettingQueryEPL,
"hf Filled List": hfFilledListEPL,
"place Order": placeOrderEPL,
"place Bulk Orders": placeBulkOrdersEPL,
"cancel Order": cancelOrderEPL,
"cancel Order By Client OrderID": cancelOrderByClientOrderIDEPL,
"cancel All Orders": cancelAllOrdersEPL,
"list Orders": listOrdersEPL,
"recent Orders": recentOrdersEPL,
"order Detail By ID": orderDetailByIDEPL,
"get Order By Client Supplied OrderID": getOrderByClientSuppliedOrderIDEPL,
"list Fills": listFillsEPL,
"get Recent Fills": getRecentFillsEPL,
"place Stop Order": placeStopOrderEPL,
"cancel Stop Order": cancelStopOrderEPL,
"cancel Stop Order By ClientID": cancelStopOrderByClientIDEPL,
"cancel Stop Orders": cancelStopOrdersEPL,
"list Stop Orders": listStopOrdersEPL,
"get Stop Order Detail": getStopOrderDetailEPL,
"get Stop Order By ClientID": getStopOrderByClientIDEPL,
"place OCO Order": placeOCOOrderEPL,
"cancel OCOOrder By ID": cancelOCOOrderByIDEPL,
"cancel Multiple OCO Orders": cancelMultipleOCOOrdersEPL,
"get OCO Order By ID": getOCOOrderByIDEPL,
"get OCO Order Details By OrderID": getOCOOrderDetailsByOrderIDEPL,
"get OCO Orders": getOCOOrdersEPL,
"place Margin Order": placeMarginOrderEPL,
"cancel Margin HF Order By ID": cancelMarginHFOrderByIDEPL,
"get Margin HF Order Detail By ID": getMarginHFOrderDetailByID,
"cancel All Margin HF Orders By Symbol": cancelAllMarginHFOrdersBySymbolEPL,
"get Active Margin HF Orders": getActiveMarginHFOrdersEPL,
"get Filled HF Margin Orders": getFilledHFMarginOrdersEPL,
"get Margin HF Order Detail By Order ID": getMarginHFOrderDetailByOrderIDEPL,
"get Margin HF Trade Fills": getMarginHFTradeFillsEPL,
"place Margin Orders": placeMarginOrdersEPL,
"leveraged Token Info": leveragedTokenInfoEPL,
"get Mark Price": getMarkPriceEPL,
"get Margin Configuration": getMarginConfigurationEPL,
"cross Isolated Margin Risk Limit Currency Config": crossIsolatedMarginRiskLimitCurrencyConfigEPL,
"isolated Margin Pair Config": isolatedMarginPairConfigEPL,
"isolated Margin Account Info": isolatedMarginAccountInfoEPL,
"single Isolated Margin Account Info": singleIsolatedMarginAccountInfoEPL,
"post Margin Borrow Order": postMarginBorrowOrderEPL,
"post Margin Repayment": postMarginRepaymentEPL,
"margin Borrowing History": marginBorrowingHistoryEPL,
"margin Repayment History": marginRepaymentHistoryEPL,
"lending Currency Info": lendingCurrencyInfoEPL,
"interest Rate": interestRateEPL,
"margin Lending Subscription": marginLendingSubscriptionEPL,
"redemption": redemptionEPL,
"modify Subscription": modifySubscriptionEPL,
"get Redemption Orders": getRedemptionOrdersEPL,
"get Subscription Orders": getSubscriptionOrdersEPL,
"futures Open Contracts": futuresOpenContractsEPL,
"futures Contract": futuresContractEPL,
"futures Ticker": futuresTickerEPL,
"futures Orderbook": futuresOrderbookEPL,
"futures Part Orderbook Depth20": futuresPartOrderbookDepth20EPL,
"futures Part Orderbook Depth100": futuresPartOrderbookDepth100EPL,
"futures Transaction History": futuresTransactionHistoryEPL,
"futures Kline": futuresKlineEPL,
"futures Interest Rate": futuresInterestRateEPL,
"futures Index List": futuresIndexListEPL,
"futures Current Mark Price": futuresCurrentMarkPriceEPL,
"futures Premium Index": futuresPremiumIndexEPL,
"futures Transaction Volume": futuresTransactionVolumeEPL,
"futures Server Time": futuresServerTimeEPL,
"futures Service Status": futuresServiceStatusEPL,
"multiple Futures Orders": multipleFuturesOrdersEPL,
"futures Cancel An Order": futuresCancelAnOrderEPL,
"futures Place Order": futuresPlaceOrderEPL,
"futures Limit Order Mass Cancellation": futuresLimitOrderMassCancelationEPL,
"cancel Untriggered Futures Stop Orders": cancelUntriggeredFuturesStopOrdersEPL,
"futures Cancel Multiple Limit Orders": futuresCancelMultipleLimitOrdersEPL,
"futures Retrieve Order List": futuresRetrieveOrderListEPL,
"futures Recent Completed Orders": futuresRecentCompletedOrdersEPL,
"futures Orders By ID": futuresOrdersByIDEPL,
"futures Retrieve Fills": futuresRetrieveFillsEPL,
"futures Recent Fills": futuresRecentFillsEPL,
"futures Open Order Stats": futuresOpenOrderStatsEPL,
"futures Position": futuresPositionEPL,
"futures Position List": futuresPositionListEPL,
"set Auto Deposit Margin": setAutoDepositMarginEPL,
"max Withdraw Margin": maxWithdrawMarginEPL,
"remove Margin Manually": removeMarginManuallyEPL,
"futures Add Margin Manually": futuresAddMarginManuallyEPL,
"futures Risk Limit Level": futuresRiskLimitLevelEPL,
"futures Update Risk Limit Level": futuresUpdateRiskLimitLevelEPL,
"futures Current Funding Rate": futuresCurrentFundingRateEPL,
"futures Public Funding Rate": futuresPublicFundingRateEPL,
"futures Funding History": futuresFundingHistoryEPL,
"spot Authentication": spotAuthenticationEPL,
"futures Authentication": futuresAuthenticationEPL,
"futures Order Details By Client Order ID": futuresOrderDetailsByClientOrderIDEPL,
"modify Sub Account API": modifySubAccountAPIEPL,
"all Sub Accounts Balance": allSubAccountsBalanceEPL,
"all User Sub Accounts V2": allUserSubAccountsV2EPL,
"futures Retrieve Transaction History": futuresRetrieveTransactionHistoryEPL,
"futures Account Overview": futuresAccountOverviewEPL,
"create Sub Account API Key": createSubAccountAPIKeyEPL,
"transfer Out To Main": transferOutToMainEPL,
"transfer Fund To Futures Account": transferFundToFuturesAccountEPL,
"futures Transfer Out List": futuresTransferOutListEPL,
}
rl, err := request.New("rateLimitTest2", http.DefaultClient, request.WithLimiter(GetRateLimit()))
require.NoError(t, err)
for name, tt := range testTable {
t.Run(name, func(t *testing.T) {
t.Parallel()
if err := rl.InitiateRateLimit(context.Background(), tt); err != nil {
t.Fatalf("error applying rate limit: %v", err)
}
})
}
}