Files
gocryptotrader/exchanges/gateio/gateio_wrapper_test.go
Ryan O'Hara-Reid dcf98ec700 exchanges/order, GateIO: Update USDT margined futures pathway for cancel all orders (#2021)
* order/gateio: update USDT margined futures pathway for cancel all orders and drop count field

* gateio: add and expand tests for CancelAllOrders and getExchangeSide

* Add test for load

* linter: fix

* Update exchanges/kraken/kraken_wrapper.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* glorious: nits

* Update exchanges/order/orders.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* gk: nits

* glorious: nits

* reverted change for options

* Update exchanges/gateio/gateio_wrapper_test.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update exchanges/gateio/gateio_wrapper.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* Update exchanges/deribit/deribit_wrapper.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* Update exchanges/gateio/gateio_wrapper_test.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* Update exchanges/gateio/gateio_wrapper_test.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* Add consts for cancel side references

* Update exchanges/gateio/gateio_wrapper.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* Update exchanges/gateio/gateio_wrapper.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* Update exchanges/gateio/gateio_websocket_request_futures.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* thrasher-: nits

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
2025-10-02 15:50:51 +10:00

74 lines
2.2 KiB
Go

package gateio
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/sharedtestvalues"
)
func TestCancelAllOrders(t *testing.T) {
t.Parallel()
_, err := e.CancelAllOrders(t.Context(), nil)
require.ErrorIs(t, err, order.ErrCancelOrderIsNil)
_, err = e.CancelAllOrders(t.Context(), &order.Cancel{Pair: currency.EMPTYPAIR, AssetType: 1336})
require.ErrorIs(t, err, currency.ErrCurrencyPairEmpty)
_, err = e.CancelAllOrders(t.Context(), &order.Cancel{Pair: currency.NewBTCUSDT(), AssetType: 1336})
require.ErrorIs(t, err, asset.ErrNotSupported)
_, err = e.CancelAllOrders(t.Context(), &order.Cancel{
Pair: currency.NewBTCUSDT(),
AssetType: asset.Options,
Side: order.ClosePosition,
})
require.ErrorIs(t, err, order.ErrSideIsInvalid)
_, err = e.CancelAllOrders(t.Context(), &order.Cancel{
Pair: currency.NewPair(currency.BTC, currency.EMPTYCODE),
AssetType: asset.USDTMarginedFutures,
Side: order.Long,
})
require.ErrorIs(t, err, errInvalidSettlementQuote)
_, err = e.CancelAllOrders(t.Context(), &order.Cancel{
Pair: currency.NewPair(currency.BTC, currency.EMPTYCODE),
AssetType: asset.USDTMarginedFutures,
Side: order.Short,
})
require.ErrorIs(t, err, errInvalidSettlementQuote)
_, err = e.CancelAllOrders(t.Context(), &order.Cancel{
Pair: currency.NewPair(currency.BTC, currency.EMPTYCODE),
AssetType: asset.USDTMarginedFutures,
Side: order.AnySide,
})
require.ErrorIs(t, err, errInvalidSettlementQuote)
sharedtestvalues.SkipTestIfCredentialsUnset(t, e, canManipulateRealOrders)
for _, a := range e.GetAssetTypes(false) {
t.Run(a.String(), func(t *testing.T) {
t.Parallel()
r := &order.Cancel{
OrderID: "1",
AccountID: "1",
AssetType: a,
Pair: currency.EMPTYPAIR,
}
_, err := e.CancelAllOrders(t.Context(), r)
assert.ErrorIs(t, err, currency.ErrCurrencyPairEmpty)
r.Pair = getPair(t, a)
_, err = e.CancelAllOrders(t.Context(), r)
assert.NoError(t, err)
})
}
}