mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
liquidity: tweak autoloop tests for recurring budget
This commit is contained in:
parent
b025b9ae37
commit
5d6be011f9
3 changed files with 45 additions and 37 deletions
|
|
@ -95,12 +95,12 @@ func TestAutoLoopEnabled(t *testing.T) {
|
|||
// autoloop budget is set to allow exactly 2 swaps at the prices
|
||||
// that we set in our test quotes.
|
||||
params = Parameters{
|
||||
Autoloop: true,
|
||||
AutoFeeBudget: 40066,
|
||||
AutoFeeStartDate: testTime,
|
||||
MaxAutoInFlight: 2,
|
||||
FailureBackOff: time.Hour,
|
||||
SweepConfTarget: 10,
|
||||
Autoloop: true,
|
||||
AutoFeeBudget: 40066,
|
||||
AutoFeeRefreshPeriod: testBudgetRefresh,
|
||||
MaxAutoInFlight: 2,
|
||||
FailureBackOff: time.Hour,
|
||||
SweepConfTarget: 10,
|
||||
FeeLimit: NewFeeCategoryLimit(
|
||||
swapFeePPM, routeFeePPM, prepayFeePPM, maxMiner,
|
||||
prepayAmount, 20000,
|
||||
|
|
@ -112,6 +112,7 @@ func TestAutoLoopEnabled(t *testing.T) {
|
|||
HtlcConfTarget: defaultHtlcConfTarget,
|
||||
}
|
||||
)
|
||||
|
||||
c := newAutoloopTestCtx(t, params, channels, testRestrictions)
|
||||
c.start()
|
||||
|
||||
|
|
@ -335,13 +336,13 @@ func TestAutoloopAddress(t *testing.T) {
|
|||
// Create some dummy parameters for autoloop and also specify an
|
||||
// destination address.
|
||||
params = Parameters{
|
||||
Autoloop: true,
|
||||
AutoFeeBudget: 40066,
|
||||
DestAddr: addr,
|
||||
AutoFeeStartDate: testTime,
|
||||
MaxAutoInFlight: 2,
|
||||
FailureBackOff: time.Hour,
|
||||
SweepConfTarget: 10,
|
||||
Autoloop: true,
|
||||
AutoFeeBudget: 40066,
|
||||
DestAddr: addr,
|
||||
AutoFeeRefreshPeriod: testBudgetRefresh,
|
||||
MaxAutoInFlight: 2,
|
||||
FailureBackOff: time.Hour,
|
||||
SweepConfTarget: 10,
|
||||
FeeLimit: NewFeeCategoryLimit(
|
||||
swapFeePPM, routeFeePPM, prepayFeePPM, maxMiner,
|
||||
prepayAmount, 20000,
|
||||
|
|
@ -491,12 +492,12 @@ func TestCompositeRules(t *testing.T) {
|
|||
swapFeePPM, routeFeePPM, prepayFeePPM, maxMiner,
|
||||
prepayAmount, 20000,
|
||||
),
|
||||
Autoloop: true,
|
||||
AutoFeeBudget: 100000,
|
||||
AutoFeeStartDate: testTime,
|
||||
MaxAutoInFlight: 2,
|
||||
FailureBackOff: time.Hour,
|
||||
SweepConfTarget: 10,
|
||||
Autoloop: true,
|
||||
AutoFeeBudget: 100000,
|
||||
AutoFeeRefreshPeriod: testBudgetRefresh,
|
||||
MaxAutoInFlight: 2,
|
||||
FailureBackOff: time.Hour,
|
||||
SweepConfTarget: 10,
|
||||
ChannelRules: map[lnwire.ShortChannelID]*SwapRule{
|
||||
chanID1: chanRule,
|
||||
},
|
||||
|
|
@ -670,13 +671,13 @@ func TestAutoLoopInEnabled(t *testing.T) {
|
|||
peer2MaxFee = ppmToSat(peer2ExpectedAmt, swapFeePPM)
|
||||
|
||||
params = Parameters{
|
||||
Autoloop: true,
|
||||
AutoFeeBudget: peer1MaxFee + peer2MaxFee + 1,
|
||||
AutoFeeStartDate: testTime,
|
||||
MaxAutoInFlight: 2,
|
||||
FailureBackOff: time.Hour,
|
||||
FeeLimit: NewFeePortion(swapFeePPM),
|
||||
ChannelRules: make(map[lnwire.ShortChannelID]*SwapRule),
|
||||
Autoloop: true,
|
||||
AutoFeeBudget: peer1MaxFee + peer2MaxFee + 1,
|
||||
AutoFeeRefreshPeriod: testBudgetRefresh,
|
||||
MaxAutoInFlight: 2,
|
||||
FailureBackOff: time.Hour,
|
||||
FeeLimit: NewFeePortion(swapFeePPM),
|
||||
ChannelRules: make(map[lnwire.ShortChannelID]*SwapRule),
|
||||
PeerRules: map[route.Vertex]*SwapRule{
|
||||
peer1: rule,
|
||||
peer2: rule,
|
||||
|
|
@ -853,12 +854,12 @@ func TestAutoloopBothTypes(t *testing.T) {
|
|||
loopInMaxFee = ppmToSat(loopInAmount, swapFeePPM)
|
||||
|
||||
params = Parameters{
|
||||
Autoloop: true,
|
||||
AutoFeeBudget: loopOutMaxFee + loopInMaxFee + 1,
|
||||
AutoFeeStartDate: testTime,
|
||||
MaxAutoInFlight: 2,
|
||||
FailureBackOff: time.Hour,
|
||||
FeeLimit: NewFeePortion(swapFeePPM),
|
||||
Autoloop: true,
|
||||
AutoFeeBudget: loopOutMaxFee + loopInMaxFee + 1,
|
||||
AutoFeeRefreshPeriod: testBudgetRefresh,
|
||||
MaxAutoInFlight: 2,
|
||||
FailureBackOff: time.Hour,
|
||||
FeeLimit: NewFeePortion(swapFeePPM),
|
||||
ChannelRules: map[lnwire.ShortChannelID]*SwapRule{
|
||||
chanID1: outRule,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -117,7 +117,8 @@ func newAutoloopTestCtx(t *testing.T, parameters Parameters,
|
|||
testCtx.lnd.Channels = channels
|
||||
|
||||
cfg := &Config{
|
||||
AutoloopTicker: ticker.NewForce(DefaultAutoloopTicker),
|
||||
AutoloopTicker: ticker.NewForce(DefaultAutoloopTicker),
|
||||
AutoloopBudgetLastRefresh: testBudgetStart,
|
||||
Restrictions: func(_ context.Context, swapType swap.Type) (*Restrictions,
|
||||
error) {
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,11 @@ import (
|
|||
var (
|
||||
testTime = time.Date(2020, 02, 13, 0, 0, 0, 0, time.UTC)
|
||||
testBudgetStart = testTime.Add(time.Hour * -1)
|
||||
// In order to not influence existing tests we set the budget refresh
|
||||
// period to 10 years so that it will never be refreshed. This way the
|
||||
// behavior of autoloop remains identical to before recurring budget was
|
||||
// introduced.
|
||||
testBudgetRefresh = time.Hour * 24 * 365 * 10
|
||||
|
||||
chanID1 = lnwire.NewShortChanIDFromInt(1)
|
||||
chanID2 = lnwire.NewShortChanIDFromInt(2)
|
||||
|
|
@ -143,8 +148,9 @@ func newTestConfig() (*Config, *test.LndMockServices) {
|
|||
|
||||
return testRestrictions, nil
|
||||
},
|
||||
Lnd: &lnd.LndServices,
|
||||
Clock: clock.NewTestClock(testTime),
|
||||
Lnd: &lnd.LndServices,
|
||||
Clock: clock.NewTestClock(testTime),
|
||||
AutoloopBudgetLastRefresh: testBudgetStart,
|
||||
ListLoopOut: func() ([]*loopdb.LoopOut, error) {
|
||||
return nil, nil
|
||||
},
|
||||
|
|
@ -1100,8 +1106,8 @@ func TestFeeBudget(t *testing.T) {
|
|||
chanID1: chanRule,
|
||||
chanID2: chanRule,
|
||||
}
|
||||
params.AutoFeeStartDate = testBudgetStart
|
||||
params.AutoFeeBudget = testCase.budget
|
||||
params.AutoFeeRefreshPeriod = testBudgetRefresh
|
||||
params.MaxAutoInFlight = 2
|
||||
params.FeeLimit = NewFeeCategoryLimit(
|
||||
defaultSwapFeePPM, defaultRoutingFeePPM,
|
||||
|
|
@ -1758,7 +1764,7 @@ func TestBudgetWithLoopin(t *testing.T) {
|
|||
|
||||
params := defaultParameters
|
||||
params.AutoFeeBudget = budget
|
||||
params.AutoFeeStartDate = testBudgetStart
|
||||
params.AutoFeeRefreshPeriod = testBudgetRefresh
|
||||
|
||||
params.FeeLimit = NewFeePortion(testPPM)
|
||||
params.ChannelRules = map[lnwire.ShortChannelID]*SwapRule{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue