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

Commit

Permalink
Delete previous volume filter tests (#617)
Browse files Browse the repository at this point in the history
* vf-testing-strategy

* Revert "vf-testing-strategy"

This reverts commit d0a9e4f.

* Initial commit
  • Loading branch information
debnil authored Dec 12, 2020
1 parent fa2fed9 commit e41133f
Showing 1 changed file with 0 additions and 177 deletions.
177 changes: 0 additions & 177 deletions plugins/volumeFilter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1124,183 +1124,6 @@ func runTestVolumeFilterFn(
})
}

func TestVolumeFilterFn(t *testing.T) {
testCases := []struct {
name string
mode volumeFilterMode
baseCapInBase *float64
baseCapInQuote *float64
otbBase *float64
otbQuote *float64
tbbBase *float64
tbbQuote *float64
inputOp *txnbuild.ManageSellOffer
wantOp *txnbuild.ManageSellOffer
wantTbbBase *float64
wantTbbQuote *float64
}{
{
name: "1. selling, base units sell cap, don't keep selling base, exact mode",
mode: volumeFilterModeExact,
baseCapInBase: pointy.Float64(0.0),
baseCapInQuote: nil,
otbBase: pointy.Float64(0.0),
otbQuote: pointy.Float64(0.0),
tbbBase: pointy.Float64(0.0),
tbbQuote: pointy.Float64(0.0),
inputOp: makeManageSellOffer("2.0", "100.0"),
wantOp: nil,
wantTbbBase: pointy.Float64(0.0),
wantTbbQuote: pointy.Float64(0.0),
},
{
name: "2. selling, base units sell cap, don't keep selling base, ignore mode",
mode: volumeFilterModeIgnore,
baseCapInBase: pointy.Float64(0.0),
baseCapInQuote: nil,
otbBase: pointy.Float64(0.0),
otbQuote: pointy.Float64(0.0),
tbbBase: pointy.Float64(0.0),
tbbQuote: pointy.Float64(0.0),
inputOp: makeManageSellOffer("2.0", "100.0"),
wantOp: nil,
wantTbbBase: pointy.Float64(0.0),
wantTbbQuote: pointy.Float64(0.0),
},
{
name: "3. selling, base units sell cap, keep selling base, exact mode",
mode: volumeFilterModeExact,
baseCapInBase: pointy.Float64(1.0),
baseCapInQuote: nil,
otbBase: pointy.Float64(0.0),
otbQuote: pointy.Float64(0.0),
tbbBase: pointy.Float64(0.0),
tbbQuote: pointy.Float64(0.0),
inputOp: makeManageSellOffer("2.0", "100.0"),
wantOp: makeManageSellOffer("2.0", "1.0000000"),
wantTbbBase: pointy.Float64(1.0),
wantTbbQuote: pointy.Float64(2.0),
},
{
name: "4. selling, base units sell cap, keep selling base, ignore mode",
mode: volumeFilterModeIgnore,
baseCapInBase: pointy.Float64(1.0),
baseCapInQuote: nil,
otbBase: pointy.Float64(0.0),
otbQuote: pointy.Float64(0.0),
tbbBase: pointy.Float64(0.0),
tbbQuote: pointy.Float64(0.0),
inputOp: makeManageSellOffer("2.0", "100.0"),
wantOp: nil,
wantTbbBase: pointy.Float64(0.0),
wantTbbQuote: pointy.Float64(0.0),
},
{
name: "7. selling, quote units sell cap, don't keep selling quote, exact mode",
mode: volumeFilterModeExact,
baseCapInBase: nil,
baseCapInQuote: pointy.Float64(0),
otbBase: pointy.Float64(0.0),
otbQuote: pointy.Float64(0.0),
tbbBase: pointy.Float64(0.0),
tbbQuote: pointy.Float64(0.0),
inputOp: makeManageSellOffer("2.0", "100.0"),
wantOp: nil,
wantTbbBase: pointy.Float64(0.0),
wantTbbQuote: pointy.Float64(0.0),
},
{
name: "8. selling, quote units sell cap, don't keep selling quote, ignore mode",
mode: volumeFilterModeIgnore,
baseCapInBase: nil,
baseCapInQuote: pointy.Float64(0),
otbBase: pointy.Float64(0.0),
otbQuote: pointy.Float64(0.0),
tbbBase: pointy.Float64(0.0),
tbbQuote: pointy.Float64(0.0),
inputOp: makeManageSellOffer("2.0", "100.0"),
wantOp: nil,
wantTbbBase: pointy.Float64(0.0),
wantTbbQuote: pointy.Float64(0.0),
},
{
name: "9. selling, quote units sell cap, keep selling quote, exact mode",
mode: volumeFilterModeExact,
baseCapInBase: nil,
baseCapInQuote: pointy.Float64(1.0),
otbBase: pointy.Float64(0.0),
otbQuote: pointy.Float64(0.0),
tbbBase: pointy.Float64(0.0),
tbbQuote: pointy.Float64(0.0),
inputOp: makeManageSellOffer("2.0", "100.0"),
wantOp: makeManageSellOffer("2.0", "0.5000000"),
wantTbbBase: pointy.Float64(0.5),
wantTbbQuote: pointy.Float64(1.0),
},
{
name: "10. selling, quote units sell cap, keep selling quote, ignore mode",
mode: volumeFilterModeIgnore,
baseCapInBase: nil,
baseCapInQuote: pointy.Float64(1.0),
otbBase: pointy.Float64(0.0),
otbQuote: pointy.Float64(0.0),
tbbBase: pointy.Float64(0.0),
tbbQuote: pointy.Float64(0.0),
inputOp: makeManageSellOffer("2.0", "100.0"),
wantOp: nil,
wantTbbBase: pointy.Float64(0.0),
wantTbbQuote: pointy.Float64(0.0),
},
}

// we fix the marketIDs and accountIDs, since volumeFilterFn output does not depend on them
marketIDs := []string{}
accountIDs := []string{}

for _, k := range testCases {
for _, action := range []queries.DailyVolumeAction{queries.DailyVolumeActionSell} {
t.Run(k.name, func(t *testing.T) {
// exactly one of the two cap values must be set
if k.baseCapInBase == nil && k.baseCapInQuote == nil {
assert.Fail(t, "either one of the two cap values must be set")
return
}

if k.baseCapInBase != nil && k.baseCapInQuote != nil {
assert.Fail(t, "both of the cap values cannot be set")
return
}

dailyOTB := makeRawVolumeFilterConfig(k.otbBase, k.otbQuote, action, k.mode, marketIDs, accountIDs)
dailyTBBAccumulator := makeRawVolumeFilterConfig(k.tbbBase, k.tbbQuote, action, k.mode, marketIDs, accountIDs)
lp := limitParameters{
baseAssetCapInBaseUnits: k.baseCapInBase,
baseAssetCapInQuoteUnits: k.baseCapInQuote,
mode: k.mode,
}

actual, e := volumeFilterFn(dailyOTB, dailyTBBAccumulator, k.inputOp, utils.NativeAsset, utils.NativeAsset, lp)
if !assert.Nil(t, e) {
return
}
assert.Equal(t, k.wantOp, actual)

wantTBBAccumulator := makeRawVolumeFilterConfig(k.wantTbbBase, k.wantTbbQuote, action, k.mode, marketIDs, accountIDs)
assert.Equal(t, wantTBBAccumulator, dailyTBBAccumulator)
})
}
}
}

func makeManageSellOffer(price string, amount string) *txnbuild.ManageSellOffer {
return &txnbuild.ManageSellOffer{
Buying: txnbuild.NativeAsset{},
Selling: txnbuild.NativeAsset{},
Price: price,
Amount: amount,
}
}

func makeSellOpAmtPrice(amount float64, price float64) *txnbuild.ManageSellOffer {
return &txnbuild.ManageSellOffer{
Buying: txnbuild.NativeAsset{},
Expand Down

0 comments on commit e41133f

Please sign in to comment.