Exchanges: Remove WalletAddress (#1882)

* Exchanges: Remove cancel order walletAddress

* Order: Refactor TestMatchFilter

TestMatchFilter had inconsistent testing of empty values, and was
painful when a field was removed due to index methodology.
This should provide equal test clarity, but improve maintainability and
improve coverage on empty values.
This commit is contained in:
Gareth Kirwan
2025-04-30 09:10:36 +02:00
committed by GitHub
parent 88ac5274c9
commit c2d876d8b0
29 changed files with 5321 additions and 5375 deletions

View File

@@ -7,7 +7,6 @@ import (
"time"
"github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/core"
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/encoding/json"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
@@ -483,11 +482,10 @@ func TestCancelExchangeOrder(t *testing.T) {
currencyPair := currency.NewPair(currency.BTC, currency.LTC)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
}
err := a.CancelOrder(context.Background(), orderCancellation)
@@ -505,11 +503,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
currencyPair := currency.NewPair(currency.BTC, currency.LTC)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
}
resp, err := a.CancelAllOrders(context.Background(), orderCancellation)

View File

@@ -1655,11 +1655,10 @@ func TestCancelExchangeOrder(t *testing.T) {
sharedtestvalues.SkipTestIfCannotManipulateOrders(t, b, canManipulateRealOrders)
}
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currency.NewPair(currency.LTC, currency.BTC),
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currency.NewPair(currency.LTC, currency.BTC),
AssetType: asset.Spot,
}
err := b.CancelOrder(context.Background(), orderCancellation)
@@ -1680,11 +1679,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
sharedtestvalues.SkipTestIfCannotManipulateOrders(t, b, canManipulateRealOrders)
}
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currency.NewPair(currency.LTC, currency.BTC),
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currency.NewPair(currency.LTC, currency.BTC),
AssetType: asset.Spot,
}
_, err := b.CancelAllOrders(context.Background(), orderCancellation)

View File

@@ -14,7 +14,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/core"
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/encoding/json"
"github.com/thrasher-corp/gocryptotrader/exchange/websocket"
@@ -951,11 +950,10 @@ func TestCancelExchangeOrder(t *testing.T) {
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
}
err := b.CancelOrder(context.Background(), orderCancellation)
@@ -973,11 +971,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
}
resp, err := b.CancelAllOrders(context.Background(), orderCancellation)

View File

@@ -320,11 +320,10 @@ func TestCancelExchangeOrder(t *testing.T) {
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
}
err := b.CancelOrder(context.Background(), orderCancellation)
@@ -340,11 +339,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
}
_, err := b.CancelAllOrders(context.Background(), orderCancellation)

View File

@@ -11,7 +11,6 @@ import (
"github.com/stretchr/testify/require"
"github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/config"
"github.com/thrasher-corp/gocryptotrader/core"
"github.com/thrasher-corp/gocryptotrader/currency"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
@@ -416,11 +415,10 @@ func TestCancelExchangeOrder(t *testing.T) {
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
}
err := b.CancelOrder(context.Background(), orderCancellation)
@@ -433,11 +431,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
}
resp, err := b.CancelAllOrders(context.Background(), orderCancellation)

View File

@@ -543,11 +543,10 @@ func TestCancelExchangeOrder(t *testing.T) {
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
orderCancellation := &order.Cancel{
OrderID: "123456789012345678901234567890123456",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Futures,
OrderID: "123456789012345678901234567890123456",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Futures,
}
err := b.CancelOrder(context.Background(), orderCancellation)
@@ -564,11 +563,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
orderCancellation := &order.Cancel{
OrderID: "123456789012345678901234567890123456",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Futures,
OrderID: "123456789012345678901234567890123456",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Futures,
}
resp, err := b.CancelAllOrders(context.Background(), orderCancellation)

View File

@@ -12,7 +12,6 @@ import (
"github.com/thrasher-corp/gocryptotrader/common"
"github.com/thrasher-corp/gocryptotrader/common/key"
"github.com/thrasher-corp/gocryptotrader/config"
"github.com/thrasher-corp/gocryptotrader/core"
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/exchange/websocket"
exchange "github.com/thrasher-corp/gocryptotrader/exchanges"
@@ -440,11 +439,10 @@ func TestCancelExchangeOrder(t *testing.T) {
// TODO: Place an order to make sure we can cancel it
orderCancellation := &order.Cancel{
OrderID: "b334ecef-2b42-4998-b8a4-b6b14f6d2671",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: spotPair,
AssetType: asset.Spot,
OrderID: "b334ecef-2b42-4998-b8a4-b6b14f6d2671",
AccountID: "1",
Pair: spotPair,
AssetType: asset.Spot,
}
err := b.CancelOrder(context.Background(), orderCancellation)
assert.NoError(t, err, "CancelOrder should not error")
@@ -464,11 +462,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, b, canManipulateRealOrders)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: spotPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: spotPair,
AssetType: asset.Spot,
}
resp, err := b.CancelAllOrders(context.Background(), orderCancellation)

View File

@@ -528,11 +528,10 @@ func TestCancelExchangeOrder(t *testing.T) {
sharedtestvalues.SkipTestIfCannotManipulateOrders(t, c, canManipulateRealOrders)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: testPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: testPair,
AssetType: asset.Spot,
}
err := c.CancelOrder(context.Background(), orderCancellation)
@@ -549,11 +548,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
sharedtestvalues.SkipTestIfCannotManipulateOrders(t, c, canManipulateRealOrders)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: testPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: testPair,
AssetType: asset.Spot,
}
resp, err := c.CancelAllOrders(context.Background(), orderCancellation)

View File

@@ -313,11 +313,10 @@ func TestCancelExchangeOrder(t *testing.T) {
currencyPair := currency.NewPair(currency.BTC, currency.USD)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
}
err := c.CancelOrder(context.Background(), orderCancellation)
@@ -335,11 +334,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
}
resp, err := c.CancelAllOrders(context.Background(), orderCancellation)

View File

@@ -3486,11 +3486,10 @@ func TestCancelAllOrders(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCredentialsUnset(t, d, canManipulateRealOrders)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: futuresTradablePair,
AssetType: asset.Futures,
OrderID: "1",
AccountID: "1",
Pair: futuresTradablePair,
AssetType: asset.Futures,
}
var result order.CancelAllResponse
var err error
@@ -3739,9 +3738,8 @@ func TestCancelOrder(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCredentialsUnset(t, d, canManipulateRealOrders)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
OrderID: "1",
AccountID: "1",
}
for assetType, cp := range assetTypeToPairsMap {
orderCancellation.AssetType = assetType

View File

@@ -322,11 +322,10 @@ func TestCancelExchangeOrder(t *testing.T) {
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
}
err := e.CancelOrder(context.Background(), orderCancellation)
@@ -344,11 +343,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
}
resp, err := e.CancelAllOrders(context.Background(), orderCancellation)

View File

@@ -453,11 +453,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
}
resp, err := g.CancelAllOrders(context.Background(), orderCancellation)

View File

@@ -339,11 +339,10 @@ func TestCancelExchangeOrder(t *testing.T) {
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
}
err := h.CancelOrder(context.Background(), orderCancellation)
@@ -361,11 +360,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
}
resp, err := h.CancelAllOrders(context.Background(), orderCancellation)

View File

@@ -1199,11 +1199,10 @@ func TestCancelExchangeOrder(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCredentialsUnset(t, h, canManipulateRealOrders)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: btcusdtPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: btcusdtPair,
AssetType: asset.Spot,
}
err := h.CancelOrder(context.Background(), orderCancellation)
@@ -1215,11 +1214,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, h, canManipulateRealOrders)
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
orderCancellation := order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
}
_, err := h.CancelAllOrders(context.Background(), &orderCancellation)

View File

@@ -2658,11 +2658,10 @@ func TestCancelOrder(t *testing.T) {
t.Parallel()
sharedtestvalues.SkipTestIfCredentialsUnset(t, ku, canManipulateRealOrders)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: futuresTradablePair,
AssetType: asset.Options,
OrderID: "1",
AccountID: "1",
Pair: futuresTradablePair,
AssetType: asset.Options,
}
err := ku.CancelOrder(context.Background(), orderCancellation)
require.ErrorIs(t, err, asset.ErrNotSupported)

View File

@@ -3560,9 +3560,8 @@ func TestSubmitOrder(t *testing.T) {
func TestCancelOrder(t *testing.T) {
t.Parallel()
arg := &order.Cancel{
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
AssetType: asset.Binary,
AccountID: "1",
AssetType: asset.Binary,
}
err := ok.CancelOrder(contextGenerate(), arg)
require.ErrorIs(t, err, asset.ErrNotSupported)
@@ -3577,22 +3576,17 @@ func TestCancelOrder(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, ok, canManipulateRealOrders)
err = ok.CancelOrder(contextGenerate(), &order.Cancel{
OrderID: "1", WalletAddress: core.BitcoinDonationAddress,
AccountID: "1", Pair: spotTP, AssetType: asset.Spot,
OrderID: "1", AccountID: "1", Pair: spotTP, AssetType: asset.Spot,
})
assert.NoError(t, err)
err = ok.CancelOrder(contextGenerate(), &order.Cancel{
Type: order.OCO,
OrderID: "1", WalletAddress: core.BitcoinDonationAddress,
AccountID: "1", Pair: spotTP, AssetType: asset.Spot,
Type: order.OCO, OrderID: "1", AccountID: "1", Pair: spotTP, AssetType: asset.Spot,
})
assert.NoError(t, err)
err = ok.CancelOrder(contextGenerate(), &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress, AccountID: "1",
Pair: spreadTP, AssetType: asset.Spread,
OrderID: "1", AccountID: "1", Pair: spreadTP, AssetType: asset.Spread,
})
assert.NoError(t, err)
}
@@ -3605,9 +3599,8 @@ func TestCancelBatchOrders(t *testing.T) {
require.ErrorIs(t, err, order.ErrCancelOrderIsNil)
arg := order.Cancel{
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
AssetType: asset.Binary,
AccountID: "1",
AssetType: asset.Binary,
}
_, err = ok.CancelBatchOrders(contextGenerate(), []order.Cancel{arg})
require.ErrorIs(t, err, asset.ErrNotSupported)
@@ -3632,26 +3625,23 @@ func TestCancelBatchOrders(t *testing.T) {
sharedtestvalues.SkipTestIfCredentialsUnset(t, ok, canManipulateRealOrders)
orderCancellationParams := []order.Cancel{
{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: spotTP,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: spotTP,
AssetType: asset.Spot,
},
{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: perpetualSwapTP,
AssetType: asset.PerpetualSwap,
OrderID: "1",
AccountID: "1",
Pair: perpetualSwapTP,
AssetType: asset.PerpetualSwap,
},
{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Type: order.Trigger,
Pair: spotTP,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Type: order.Trigger,
Pair: spotTP,
AssetType: asset.Spot,
},
}
result, err := ok.CancelBatchOrders(contextGenerate(), orderCancellationParams)

View File

@@ -1187,7 +1187,6 @@ func TestUpdateOrderFromDetail(t *testing.T) {
AccountID: "1",
ClientID: "1",
ClientOrderID: "DukeOfWombleton",
WalletAddress: "1",
Type: 1,
Side: 1,
Status: 1,
@@ -1265,9 +1264,6 @@ func TestUpdateOrderFromDetail(t *testing.T) {
if od.ClientOrderID != "DukeOfWombleton" {
t.Error("Failed to update")
}
if od.WalletAddress != "1" {
t.Error("Failed to update")
}
if od.Type != 1 {
t.Error("Failed to update")
}
@@ -1496,109 +1492,55 @@ func TestValidationOnOrderTypes(t *testing.T) {
func TestMatchFilter(t *testing.T) {
t.Parallel()
id, err := uuid.NewV4()
if err != nil {
t.Fatal(err)
}
filters := map[int]*Filter{
0: {},
1: {Exchange: "Binance"},
2: {InternalOrderID: id},
3: {OrderID: "2222"},
4: {ClientOrderID: "3333"},
5: {ClientID: "4444"},
6: {WalletAddress: "5555"},
7: {Type: AnyType},
8: {Type: Limit},
9: {Side: AnySide},
10: {Side: Sell},
11: {Status: AnyStatus},
12: {Status: New},
13: {AssetType: asset.Spot},
14: {Pair: currency.NewPair(currency.BTC, currency.USD)},
15: {Exchange: "Binance", Type: Limit, Status: New},
16: {Exchange: "Binance", Type: AnyType},
17: {AccountID: "8888"},
}
id := uuid.Must(uuid.NewV4())
orders := map[int]Detail{
0: {},
1: {Exchange: "Binance"},
2: {InternalOrderID: id},
3: {OrderID: "2222"},
4: {ClientOrderID: "3333"},
5: {ClientID: "4444"},
6: {WalletAddress: "5555"},
7: {Type: AnyType},
8: {Type: Limit},
9: {Side: AnySide},
10: {Side: Sell},
11: {Status: AnyStatus},
12: {Status: New},
13: {AssetType: asset.Spot},
14: {Pair: currency.NewPair(currency.BTC, currency.USD)},
15: {Exchange: "Binance", Type: Limit, Status: New},
16: {AccountID: "8888"},
}
// empty filter tests
emptyFilter := filters[0]
for _, o := range orders {
if !o.MatchFilter(emptyFilter) {
t.Error("empty filter should match everything")
}
}
assert.True(t, new(Detail).MatchFilter(&Filter{}), "an empty filter should match an empty order")
assert.True(t, (&Detail{Exchange: "E", OrderID: "A", Side: Sell, Pair: currency.NewBTCUSD()}).MatchFilter(&Filter{}), "an empty filter should match any order")
tests := map[int]struct {
f *Filter
o Detail
expectedResult bool
tests := []struct {
description string
filter Filter
order Detail
result bool
}{
0: {filters[1], orders[1], true},
1: {filters[1], orders[0], false},
2: {filters[2], orders[2], true},
3: {filters[2], orders[3], false},
4: {filters[3], orders[3], true},
5: {filters[3], orders[4], false},
6: {filters[4], orders[4], true},
7: {filters[4], orders[5], false},
8: {filters[5], orders[5], true},
9: {filters[5], orders[6], false},
10: {filters[6], orders[6], true},
11: {filters[6], orders[7], false},
12: {filters[7], orders[7], true},
13: {filters[7], orders[8], true},
14: {filters[7], orders[9], true},
15: {filters[8], orders[7], false},
16: {filters[8], orders[8], true},
17: {filters[8], orders[9], false},
18: {filters[9], orders[9], true},
19: {filters[9], orders[10], true},
20: {filters[9], orders[11], true},
21: {filters[10], orders[10], true},
22: {filters[10], orders[11], false},
23: {filters[10], orders[9], false},
24: {filters[11], orders[11], true},
25: {filters[11], orders[12], true},
26: {filters[11], orders[10], true},
27: {filters[12], orders[12], true},
28: {filters[12], orders[13], false},
29: {filters[12], orders[11], false},
30: {filters[13], orders[13], true},
31: {filters[13], orders[12], false},
32: {filters[14], orders[14], true},
33: {filters[14], orders[13], false},
34: {filters[15], orders[15], true},
35: {filters[16], orders[15], true},
36: {filters[17], orders[16], true},
37: {filters[17], orders[15], false},
{"Exchange ✓", Filter{Exchange: "A"}, Detail{Exchange: "A"}, true},
{"Exchange 𐄂", Filter{Exchange: "A"}, Detail{Exchange: "B"}, false},
{"Exchange Empty", Filter{Exchange: "A"}, Detail{}, false},
{"InternalOrderID ✓", Filter{InternalOrderID: id}, Detail{InternalOrderID: id}, true},
{"InternalOrderID 𐄂", Filter{InternalOrderID: id}, Detail{InternalOrderID: uuid.Must(uuid.NewV4())}, false},
{"InternalOrderID Empty", Filter{InternalOrderID: id}, Detail{}, false},
{"OrderID ✓", Filter{OrderID: "A"}, Detail{OrderID: "A"}, true},
{"OrderID 𐄂", Filter{OrderID: "A"}, Detail{OrderID: "B"}, false},
{"OrderID Empty", Filter{OrderID: "A"}, Detail{}, false},
{"ClientOrderID ✓", Filter{ClientOrderID: "A"}, Detail{ClientOrderID: "A"}, true},
{"ClientOrderID 𐄂", Filter{ClientOrderID: "A"}, Detail{ClientOrderID: "B"}, false},
{"ClientOrderID Empty", Filter{ClientOrderID: "A"}, Detail{}, false},
{"ClientID ✓", Filter{ClientID: "A"}, Detail{ClientID: "A"}, true},
{"ClientID 𐄂", Filter{ClientID: "A"}, Detail{ClientID: "B"}, false},
{"ClientID Empty", Filter{ClientID: "A"}, Detail{}, false},
{"AnySide Buy", Filter{Side: AnySide}, Detail{Side: Buy}, true},
{"AnySide Sell", Filter{Side: AnySide}, Detail{Side: Sell}, true},
{"AnySide Empty", Filter{Side: AnySide}, Detail{}, true},
{"Side ✓", Filter{Side: Buy}, Detail{Side: Buy}, true},
{"Side 𐄂", Filter{Side: Buy}, Detail{Side: Sell}, false},
{"Side Empty", Filter{Side: Buy}, Detail{}, false},
{"Status ✓", Filter{Status: Open}, Detail{Status: Open}, true},
{"Status 𐄂", Filter{Status: Open}, Detail{Status: New}, false},
{"Status Empty", Filter{Status: Open}, Detail{}, false},
{"AssetType ✓", Filter{AssetType: asset.Spot}, Detail{AssetType: asset.Spot}, true},
{"AssetType 𐄂", Filter{AssetType: asset.Spot}, Detail{AssetType: asset.Index}, false},
{"AssetType Empty", Filter{AssetType: asset.Spot}, Detail{}, false},
{"Pair ✓", Filter{Pair: currency.NewBTCUSDT()}, Detail{Pair: currency.NewBTCUSDT()}, true},
{"Pair 𐄂", Filter{Pair: currency.NewBTCUSDT()}, Detail{Pair: currency.NewBTCUSD()}, false},
{"Pair Empty", Filter{Pair: currency.NewBTCUSDT()}, Detail{}, false},
{"AccountID ✓", Filter{AccountID: "A"}, Detail{AccountID: "A"}, true},
{"AccountID 𐄂", Filter{AccountID: "A"}, Detail{AccountID: "B"}, false},
{"AccountID Empty", Filter{AccountID: "A"}, Detail{}, false},
}
// specific tests
for num, tt := range tests {
t.Run(strconv.Itoa(num), func(t *testing.T) {
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
t.Parallel()
if tt.o.MatchFilter(tt.f) != tt.expectedResult {
t.Errorf("tests[%v] failed", num)
}
require.Equal(t, tt.result, tt.order.MatchFilter(&tt.filter), "MatchFilter must return correctly")
})
}
}
@@ -1958,7 +1900,6 @@ func TestDeriveCancel(t *testing.T) {
AccountID: "wow2",
ClientID: "wow3",
ClientOrderID: "wow4",
WalletAddress: "wow5",
Type: Market,
Side: Long,
Pair: pair,
@@ -1973,7 +1914,6 @@ func TestDeriveCancel(t *testing.T) {
cancel.AccountID != "wow2" ||
cancel.ClientID != "wow3" ||
cancel.ClientOrderID != "wow4" ||
cancel.WalletAddress != "wow5" ||
cancel.Type != Market ||
cancel.Side != Long ||
!cancel.Pair.Equal(pair) ||

View File

@@ -232,7 +232,6 @@ type Detail struct {
ClientOrderID string
AccountID string
ClientID string
WalletAddress string
Type Type
Side Side
Status Status
@@ -255,7 +254,6 @@ type Filter struct {
ClientOrderID string
AccountID string
ClientID string
WalletAddress string
Type Type
Side Side
Status Status
@@ -273,7 +271,6 @@ type Cancel struct {
ClientOrderID string
AccountID string
ClientID string
WalletAddress string
Type Type
Side Side
AssetType asset.Item

View File

@@ -229,10 +229,6 @@ func (d *Detail) UpdateOrderFromDetail(m *Detail) error {
d.ClientOrderID = m.ClientOrderID
updated = true
}
if m.WalletAddress != "" && m.WalletAddress != d.WalletAddress {
d.WalletAddress = m.WalletAddress
updated = true
}
if m.Type != UnknownType && m.Type != d.Type {
d.Type = m.Type
updated = true
@@ -385,7 +381,7 @@ func (d *Detail) UpdateOrderFromModifyResponse(m *ModifyResponse) {
// empty elements are ignored
func (d *Detail) MatchFilter(f *Filter) bool {
switch {
case f.Exchange != "" && !strings.EqualFold(d.Exchange, f.Exchange):
case f.Exchange != "" && d.Exchange != f.Exchange:
return false
case f.AssetType != asset.Empty && d.AssetType != f.AssetType:
return false
@@ -407,8 +403,6 @@ func (d *Detail) MatchFilter(f *Filter) bool {
return false
case f.AccountID != "" && d.AccountID != f.AccountID:
return false
case f.WalletAddress != "" && d.WalletAddress != f.WalletAddress:
return false
default:
return true
}
@@ -681,7 +675,6 @@ func (d *Detail) DeriveCancel() (*Cancel, error) {
AccountID: d.AccountID,
ClientID: d.ClientID,
ClientOrderID: d.ClientOrderID,
WalletAddress: d.WalletAddress,
Type: d.Type,
Side: d.Side,
Pair: d.Pair,

View File

@@ -392,11 +392,10 @@ func TestCancelExchangeOrder(t *testing.T) {
sharedtestvalues.SkipTestIfCannotManipulateOrders(t, p, canManipulateRealOrders)
}
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currency.NewPair(currency.LTC, currency.BTC),
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currency.NewPair(currency.LTC, currency.BTC),
AssetType: asset.Spot,
}
err := p.CancelOrder(context.Background(), orderCancellation)
@@ -418,11 +417,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
}
resp, err := p.CancelAllOrders(context.Background(), orderCancellation)

View File

@@ -391,11 +391,10 @@ func TestCancelExchangeOrder(t *testing.T) {
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
}
err := y.CancelOrder(context.Background(), orderCancellation)
@@ -413,11 +412,10 @@ func TestCancelAllExchangeOrders(t *testing.T) {
currencyPair := currency.NewPair(currency.LTC, currency.BTC)
orderCancellation := &order.Cancel{
OrderID: "1",
WalletAddress: core.BitcoinDonationAddress,
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
OrderID: "1",
AccountID: "1",
Pair: currencyPair,
AssetType: asset.Spot,
}
resp, err := y.CancelAllOrders(context.Background(), orderCancellation)