Skip to content
This repository was archived by the owner on Feb 1, 2024. It is now read-only.

Commit e41133f

Browse files
authored
Delete previous volume filter tests (#617)
* vf-testing-strategy * Revert "vf-testing-strategy" This reverts commit d0a9e4f. * Initial commit
1 parent fa2fed9 commit e41133f

1 file changed

Lines changed: 0 additions & 177 deletions

File tree

plugins/volumeFilter_test.go

Lines changed: 0 additions & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,183 +1124,6 @@ func runTestVolumeFilterFn(
11241124
})
11251125
}
11261126

1127-
func TestVolumeFilterFn(t *testing.T) {
1128-
testCases := []struct {
1129-
name string
1130-
mode volumeFilterMode
1131-
baseCapInBase *float64
1132-
baseCapInQuote *float64
1133-
otbBase *float64
1134-
otbQuote *float64
1135-
tbbBase *float64
1136-
tbbQuote *float64
1137-
inputOp *txnbuild.ManageSellOffer
1138-
wantOp *txnbuild.ManageSellOffer
1139-
wantTbbBase *float64
1140-
wantTbbQuote *float64
1141-
}{
1142-
{
1143-
name: "1. selling, base units sell cap, don't keep selling base, exact mode",
1144-
mode: volumeFilterModeExact,
1145-
baseCapInBase: pointy.Float64(0.0),
1146-
baseCapInQuote: nil,
1147-
otbBase: pointy.Float64(0.0),
1148-
otbQuote: pointy.Float64(0.0),
1149-
tbbBase: pointy.Float64(0.0),
1150-
tbbQuote: pointy.Float64(0.0),
1151-
inputOp: makeManageSellOffer("2.0", "100.0"),
1152-
wantOp: nil,
1153-
wantTbbBase: pointy.Float64(0.0),
1154-
wantTbbQuote: pointy.Float64(0.0),
1155-
},
1156-
{
1157-
name: "2. selling, base units sell cap, don't keep selling base, ignore mode",
1158-
mode: volumeFilterModeIgnore,
1159-
baseCapInBase: pointy.Float64(0.0),
1160-
baseCapInQuote: nil,
1161-
otbBase: pointy.Float64(0.0),
1162-
otbQuote: pointy.Float64(0.0),
1163-
tbbBase: pointy.Float64(0.0),
1164-
tbbQuote: pointy.Float64(0.0),
1165-
inputOp: makeManageSellOffer("2.0", "100.0"),
1166-
wantOp: nil,
1167-
wantTbbBase: pointy.Float64(0.0),
1168-
wantTbbQuote: pointy.Float64(0.0),
1169-
},
1170-
{
1171-
name: "3. selling, base units sell cap, keep selling base, exact mode",
1172-
mode: volumeFilterModeExact,
1173-
baseCapInBase: pointy.Float64(1.0),
1174-
baseCapInQuote: nil,
1175-
otbBase: pointy.Float64(0.0),
1176-
otbQuote: pointy.Float64(0.0),
1177-
tbbBase: pointy.Float64(0.0),
1178-
tbbQuote: pointy.Float64(0.0),
1179-
inputOp: makeManageSellOffer("2.0", "100.0"),
1180-
wantOp: makeManageSellOffer("2.0", "1.0000000"),
1181-
wantTbbBase: pointy.Float64(1.0),
1182-
wantTbbQuote: pointy.Float64(2.0),
1183-
},
1184-
{
1185-
name: "4. selling, base units sell cap, keep selling base, ignore mode",
1186-
mode: volumeFilterModeIgnore,
1187-
baseCapInBase: pointy.Float64(1.0),
1188-
baseCapInQuote: nil,
1189-
otbBase: pointy.Float64(0.0),
1190-
otbQuote: pointy.Float64(0.0),
1191-
tbbBase: pointy.Float64(0.0),
1192-
tbbQuote: pointy.Float64(0.0),
1193-
inputOp: makeManageSellOffer("2.0", "100.0"),
1194-
wantOp: nil,
1195-
wantTbbBase: pointy.Float64(0.0),
1196-
wantTbbQuote: pointy.Float64(0.0),
1197-
},
1198-
{
1199-
name: "7. selling, quote units sell cap, don't keep selling quote, exact mode",
1200-
mode: volumeFilterModeExact,
1201-
baseCapInBase: nil,
1202-
baseCapInQuote: pointy.Float64(0),
1203-
otbBase: pointy.Float64(0.0),
1204-
otbQuote: pointy.Float64(0.0),
1205-
tbbBase: pointy.Float64(0.0),
1206-
tbbQuote: pointy.Float64(0.0),
1207-
inputOp: makeManageSellOffer("2.0", "100.0"),
1208-
wantOp: nil,
1209-
wantTbbBase: pointy.Float64(0.0),
1210-
wantTbbQuote: pointy.Float64(0.0),
1211-
},
1212-
{
1213-
name: "8. selling, quote units sell cap, don't keep selling quote, ignore mode",
1214-
mode: volumeFilterModeIgnore,
1215-
baseCapInBase: nil,
1216-
baseCapInQuote: pointy.Float64(0),
1217-
otbBase: pointy.Float64(0.0),
1218-
otbQuote: pointy.Float64(0.0),
1219-
tbbBase: pointy.Float64(0.0),
1220-
tbbQuote: pointy.Float64(0.0),
1221-
inputOp: makeManageSellOffer("2.0", "100.0"),
1222-
wantOp: nil,
1223-
wantTbbBase: pointy.Float64(0.0),
1224-
wantTbbQuote: pointy.Float64(0.0),
1225-
},
1226-
{
1227-
name: "9. selling, quote units sell cap, keep selling quote, exact mode",
1228-
mode: volumeFilterModeExact,
1229-
baseCapInBase: nil,
1230-
baseCapInQuote: pointy.Float64(1.0),
1231-
otbBase: pointy.Float64(0.0),
1232-
otbQuote: pointy.Float64(0.0),
1233-
tbbBase: pointy.Float64(0.0),
1234-
tbbQuote: pointy.Float64(0.0),
1235-
inputOp: makeManageSellOffer("2.0", "100.0"),
1236-
wantOp: makeManageSellOffer("2.0", "0.5000000"),
1237-
wantTbbBase: pointy.Float64(0.5),
1238-
wantTbbQuote: pointy.Float64(1.0),
1239-
},
1240-
{
1241-
name: "10. selling, quote units sell cap, keep selling quote, ignore mode",
1242-
mode: volumeFilterModeIgnore,
1243-
baseCapInBase: nil,
1244-
baseCapInQuote: pointy.Float64(1.0),
1245-
otbBase: pointy.Float64(0.0),
1246-
otbQuote: pointy.Float64(0.0),
1247-
tbbBase: pointy.Float64(0.0),
1248-
tbbQuote: pointy.Float64(0.0),
1249-
inputOp: makeManageSellOffer("2.0", "100.0"),
1250-
wantOp: nil,
1251-
wantTbbBase: pointy.Float64(0.0),
1252-
wantTbbQuote: pointy.Float64(0.0),
1253-
},
1254-
}
1255-
1256-
// we fix the marketIDs and accountIDs, since volumeFilterFn output does not depend on them
1257-
marketIDs := []string{}
1258-
accountIDs := []string{}
1259-
1260-
for _, k := range testCases {
1261-
for _, action := range []queries.DailyVolumeAction{queries.DailyVolumeActionSell} {
1262-
t.Run(k.name, func(t *testing.T) {
1263-
// exactly one of the two cap values must be set
1264-
if k.baseCapInBase == nil && k.baseCapInQuote == nil {
1265-
assert.Fail(t, "either one of the two cap values must be set")
1266-
return
1267-
}
1268-
1269-
if k.baseCapInBase != nil && k.baseCapInQuote != nil {
1270-
assert.Fail(t, "both of the cap values cannot be set")
1271-
return
1272-
}
1273-
1274-
dailyOTB := makeRawVolumeFilterConfig(k.otbBase, k.otbQuote, action, k.mode, marketIDs, accountIDs)
1275-
dailyTBBAccumulator := makeRawVolumeFilterConfig(k.tbbBase, k.tbbQuote, action, k.mode, marketIDs, accountIDs)
1276-
lp := limitParameters{
1277-
baseAssetCapInBaseUnits: k.baseCapInBase,
1278-
baseAssetCapInQuoteUnits: k.baseCapInQuote,
1279-
mode: k.mode,
1280-
}
1281-
1282-
actual, e := volumeFilterFn(dailyOTB, dailyTBBAccumulator, k.inputOp, utils.NativeAsset, utils.NativeAsset, lp)
1283-
if !assert.Nil(t, e) {
1284-
return
1285-
}
1286-
assert.Equal(t, k.wantOp, actual)
1287-
1288-
wantTBBAccumulator := makeRawVolumeFilterConfig(k.wantTbbBase, k.wantTbbQuote, action, k.mode, marketIDs, accountIDs)
1289-
assert.Equal(t, wantTBBAccumulator, dailyTBBAccumulator)
1290-
})
1291-
}
1292-
}
1293-
}
1294-
1295-
func makeManageSellOffer(price string, amount string) *txnbuild.ManageSellOffer {
1296-
return &txnbuild.ManageSellOffer{
1297-
Buying: txnbuild.NativeAsset{},
1298-
Selling: txnbuild.NativeAsset{},
1299-
Price: price,
1300-
Amount: amount,
1301-
}
1302-
}
1303-
13041127
func makeSellOpAmtPrice(amount float64, price float64) *txnbuild.ManageSellOffer {
13051128
return &txnbuild.ManageSellOffer{
13061129
Buying: txnbuild.NativeAsset{},

0 commit comments

Comments
 (0)