@@ -70,32 +70,37 @@ func TestAutoLoopDisabled(t *testing.T) {
7070func TestAutoLoopEnabled (t * testing.T ) {
7171 defer test .Guard (t )()
7272
73- channels := []lndclient.ChannelInfo {
74- channel1 , channel2 ,
75- }
76-
77- // Create a set of parameters with autoloop enabled. The autoloop budget
78- // is set to allow exactly 2 swaps at the prices that we set in our
79- // test quotes.
80- params := Parameters {
81- Autoloop : true ,
82- AutoFeeBudget : 40066 ,
83- AutoFeeStartDate : testTime ,
84- MaxAutoInFlight : 2 ,
85- FailureBackOff : time .Hour ,
86- SweepFeeRateLimit : 20000 ,
87- SweepConfTarget : 10 ,
88- MaximumPrepay : 20000 ,
89- MaximumSwapFeePPM : 1000 ,
90- MaximumRoutingFeePPM : 1000 ,
91- MaximumPrepayRoutingFeePPM : 1000 ,
92- MaximumMinerFee : 20000 ,
93- ChannelRules : map [lnwire.ShortChannelID ]* ThresholdRule {
94- chanID1 : chanRule ,
95- chanID2 : chanRule ,
96- },
97- }
73+ var (
74+ channels = []lndclient.ChannelInfo {
75+ channel1 , channel2 ,
76+ }
9877
78+ swapFeePPM uint64 = 1000
79+ routeFeePPM uint64 = 1000
80+ prepayFeePPM uint64 = 1000
81+ prepayAmount = btcutil .Amount (20000 )
82+ maxMiner = btcutil .Amount (20000 )
83+
84+ // Create a set of parameters with autoloop enabled. The
85+ // autoloop budget is set to allow exactly 2 swaps at the prices
86+ // that we set in our test quotes.
87+ params = Parameters {
88+ Autoloop : true ,
89+ AutoFeeBudget : 40066 ,
90+ AutoFeeStartDate : testTime ,
91+ MaxAutoInFlight : 2 ,
92+ FailureBackOff : time .Hour ,
93+ SweepConfTarget : 10 ,
94+ FeeLimit : NewFeeCategoryLimit (
95+ swapFeePPM , routeFeePPM , prepayFeePPM , maxMiner ,
96+ prepayAmount , 20000 ,
97+ ),
98+ ChannelRules : map [lnwire.ShortChannelID ]* ThresholdRule {
99+ chanID1 : chanRule ,
100+ chanID2 : chanRule ,
101+ },
102+ }
103+ )
99104 c := newAutoloopTestCtx (t , params , channels , testRestrictions )
100105 c .start ()
101106
@@ -104,18 +109,20 @@ func TestAutoLoopEnabled(t *testing.T) {
104109 var (
105110 amt = chan1Rec .Amount
106111
107- maxSwapFee = ppmToSat (amt , params . MaximumSwapFeePPM )
112+ maxSwapFee = ppmToSat (amt , swapFeePPM )
108113
109114 // Create a quote that is within our limits. We do not set miner
110115 // fee because this value is not actually set by the server.
111116 quote1 = & loop.LoopOutQuote {
112117 SwapFee : maxSwapFee ,
113- PrepayAmount : params .MaximumPrepay - 10 ,
118+ PrepayAmount : prepayAmount - 10 ,
119+ MinerFee : maxMiner - 10 ,
114120 }
115121
116122 quote2 = & loop.LoopOutQuote {
117123 SwapFee : maxSwapFee ,
118- PrepayAmount : params .MaximumPrepay - 20 ,
124+ PrepayAmount : prepayAmount - 20 ,
125+ MinerFee : maxMiner - 10 ,
119126 }
120127
121128 quoteRequest = & loop.LoopOutQuoteRequest {
@@ -134,18 +141,17 @@ func TestAutoLoopEnabled(t *testing.T) {
134141 },
135142 }
136143
137- maxRouteFee = ppmToSat (amt , params . MaximumRoutingFeePPM )
144+ maxRouteFee = ppmToSat (amt , routeFeePPM )
138145
139146 chan1Swap = & loop.OutRequest {
140147 Amount : amt ,
141148 MaxSwapRoutingFee : maxRouteFee ,
142149 MaxPrepayRoutingFee : ppmToSat (
143- quote1 .PrepayAmount ,
144- params .MaximumPrepayRoutingFeePPM ,
150+ quote1 .PrepayAmount , prepayFeePPM ,
145151 ),
146152 MaxSwapFee : quote1 .SwapFee ,
147153 MaxPrepayAmount : quote1 .PrepayAmount ,
148- MaxMinerFee : params . MaximumMinerFee ,
154+ MaxMinerFee : maxMiner ,
149155 SweepConfTarget : params .SweepConfTarget ,
150156 OutgoingChanSet : loopdb.ChannelSet {chanID1 .ToUint64 ()},
151157 Label : labels .AutoloopLabel (swap .TypeOut ),
@@ -156,12 +162,11 @@ func TestAutoLoopEnabled(t *testing.T) {
156162 Amount : amt ,
157163 MaxSwapRoutingFee : maxRouteFee ,
158164 MaxPrepayRoutingFee : ppmToSat (
159- quote2 .PrepayAmount ,
160- params .MaximumPrepayRoutingFeePPM ,
165+ quote2 .PrepayAmount , routeFeePPM ,
161166 ),
162167 MaxSwapFee : quote2 .SwapFee ,
163168 MaxPrepayAmount : quote2 .PrepayAmount ,
164- MaxMinerFee : params . MaximumMinerFee ,
169+ MaxMinerFee : maxMiner ,
165170 SweepConfTarget : params .SweepConfTarget ,
166171 OutgoingChanSet : loopdb.ChannelSet {chanID2 .ToUint64 ()},
167172 Label : labels .AutoloopLabel (swap .TypeOut ),
@@ -216,7 +221,7 @@ func TestAutoLoopEnabled(t *testing.T) {
216221 State : loopdb .StateSuccess ,
217222 Cost : loopdb.SwapCost {
218223 Server : quote1 .SwapFee ,
219- Onchain : params . MaximumMinerFee ,
224+ Onchain : maxMiner ,
220225 Offchain : maxRouteFee +
221226 chan1Rec .MaxPrepayRoutingFee ,
222227 },
@@ -273,42 +278,48 @@ func TestAutoLoopEnabled(t *testing.T) {
273278func TestCompositeRules (t * testing.T ) {
274279 defer test .Guard (t )()
275280
276- // Setup our channels so that we have two channels with peer 2, and
277- // a single channel with peer 1.
278- channel3 := lndclient.ChannelInfo {
279- ChannelID : chanID3 .ToUint64 (),
280- PubKeyBytes : peer2 ,
281- LocalBalance : 10000 ,
282- RemoteBalance : 0 ,
283- Capacity : 10000 ,
284- }
281+ var (
282+ // Setup our channels so that we have two channels with peer 2,
283+ // and a single channel with peer 1.
284+ channel3 = lndclient.ChannelInfo {
285+ ChannelID : chanID3 .ToUint64 (),
286+ PubKeyBytes : peer2 ,
287+ LocalBalance : 10000 ,
288+ RemoteBalance : 0 ,
289+ Capacity : 10000 ,
290+ }
285291
286- channels : = []lndclient.ChannelInfo {
287- channel1 , channel2 , channel3 ,
288- }
292+ channels = []lndclient.ChannelInfo {
293+ channel1 , channel2 , channel3 ,
294+ }
289295
290- // Create a set of parameters with autoloop enabled, set our budget to
291- // a value that will easily accommodate our two swaps.
292- params := Parameters {
293- Autoloop : true ,
294- AutoFeeBudget : 100000 ,
295- AutoFeeStartDate : testTime ,
296- MaxAutoInFlight : 2 ,
297- FailureBackOff : time .Hour ,
298- SweepFeeRateLimit : 20000 ,
299- SweepConfTarget : 10 ,
300- MaximumPrepay : 20000 ,
301- MaximumSwapFeePPM : 1000 ,
302- MaximumRoutingFeePPM : 1000 ,
303- MaximumPrepayRoutingFeePPM : 1000 ,
304- MaximumMinerFee : 20000 ,
305- ChannelRules : map [lnwire.ShortChannelID ]* ThresholdRule {
306- chanID1 : chanRule ,
307- },
308- PeerRules : map [route.Vertex ]* ThresholdRule {
309- peer2 : chanRule ,
310- },
311- }
296+ swapFeePPM uint64 = 1000
297+ routeFeePPM uint64 = 1000
298+ prepayFeePPM uint64 = 1000
299+ prepayAmount = btcutil .Amount (20000 )
300+ maxMiner = btcutil .Amount (20000 )
301+
302+ // Create a set of parameters with autoloop enabled, set our
303+ // budget to a value that will easily accommodate our two swaps.
304+ params = Parameters {
305+ FeeLimit : NewFeeCategoryLimit (
306+ swapFeePPM , routeFeePPM , prepayFeePPM , maxMiner ,
307+ prepayAmount , 20000 ,
308+ ),
309+ Autoloop : true ,
310+ AutoFeeBudget : 100000 ,
311+ AutoFeeStartDate : testTime ,
312+ MaxAutoInFlight : 2 ,
313+ FailureBackOff : time .Hour ,
314+ SweepConfTarget : 10 ,
315+ ChannelRules : map [lnwire.ShortChannelID ]* ThresholdRule {
316+ chanID1 : chanRule ,
317+ },
318+ PeerRules : map [route.Vertex ]* ThresholdRule {
319+ peer2 : chanRule ,
320+ },
321+ }
322+ )
312323
313324 c := newAutoloopTestCtx (t , params , channels , testRestrictions )
314325 c .start ()
@@ -320,32 +331,30 @@ func TestCompositeRules(t *testing.T) {
320331 // our budget, with an amount which would balance the peer
321332 /// across all of its channels.
322333 peerAmount = btcutil .Amount (15000 )
323- maxPeerSwapFee = ppmToSat (peerAmount , params . MaximumSwapFeePPM )
334+ maxPeerSwapFee = ppmToSat (peerAmount , swapFeePPM )
324335
325336 peerSwapQuote = & loop.LoopOutQuote {
326337 SwapFee : maxPeerSwapFee ,
327- PrepayAmount : params .MaximumPrepay - 20 ,
338+ PrepayAmount : prepayAmount - 20 ,
339+ MinerFee : maxMiner - 10 ,
328340 }
329341
330342 peerSwapQuoteRequest = & loop.LoopOutQuoteRequest {
331343 Amount : peerAmount ,
332344 SweepConfTarget : params .SweepConfTarget ,
333345 }
334346
335- maxPeerRouteFee = ppmToSat (
336- peerAmount , params .MaximumRoutingFeePPM ,
337- )
347+ maxPeerRouteFee = ppmToSat (peerAmount , routeFeePPM )
338348
339349 peerSwap = & loop.OutRequest {
340350 Amount : peerAmount ,
341351 MaxSwapRoutingFee : maxPeerRouteFee ,
342352 MaxPrepayRoutingFee : ppmToSat (
343- peerSwapQuote .PrepayAmount ,
344- params .MaximumPrepayRoutingFeePPM ,
353+ peerSwapQuote .PrepayAmount , routeFeePPM ,
345354 ),
346355 MaxSwapFee : peerSwapQuote .SwapFee ,
347356 MaxPrepayAmount : peerSwapQuote .PrepayAmount ,
348- MaxMinerFee : params . MaximumMinerFee ,
357+ MaxMinerFee : maxMiner ,
349358 SweepConfTarget : params .SweepConfTarget ,
350359 OutgoingChanSet : loopdb.ChannelSet {
351360 chanID2 .ToUint64 (), chanID3 .ToUint64 (),
@@ -356,32 +365,30 @@ func TestCompositeRules(t *testing.T) {
356365 // Create a quote for our single channel swap that is within
357366 // our budget.
358367 chanAmount = chan1Rec .Amount
359- maxChanSwapFee = ppmToSat (chanAmount , params . MaximumSwapFeePPM )
368+ maxChanSwapFee = ppmToSat (chanAmount , swapFeePPM )
360369
361370 channelSwapQuote = & loop.LoopOutQuote {
362371 SwapFee : maxChanSwapFee ,
363- PrepayAmount : params .MaximumPrepay - 10 ,
372+ PrepayAmount : prepayAmount - 10 ,
373+ MinerFee : maxMiner - 10 ,
364374 }
365375
366376 chanSwapQuoteRequest = & loop.LoopOutQuoteRequest {
367377 Amount : chanAmount ,
368378 SweepConfTarget : params .SweepConfTarget ,
369379 }
370380
371- maxChanRouteFee = ppmToSat (
372- chanAmount , params .MaximumRoutingFeePPM ,
373- )
381+ maxChanRouteFee = ppmToSat (chanAmount , routeFeePPM )
374382
375383 chanSwap = & loop.OutRequest {
376384 Amount : chanAmount ,
377385 MaxSwapRoutingFee : maxChanRouteFee ,
378386 MaxPrepayRoutingFee : ppmToSat (
379- channelSwapQuote .PrepayAmount ,
380- params .MaximumPrepayRoutingFeePPM ,
387+ channelSwapQuote .PrepayAmount , routeFeePPM ,
381388 ),
382389 MaxSwapFee : channelSwapQuote .SwapFee ,
383390 MaxPrepayAmount : channelSwapQuote .PrepayAmount ,
384- MaxMinerFee : params . MaximumMinerFee ,
391+ MaxMinerFee : maxMiner ,
385392 SweepConfTarget : params .SweepConfTarget ,
386393 OutgoingChanSet : loopdb.ChannelSet {chanID1 .ToUint64 ()},
387394 Label : labels .AutoloopLabel (swap .TypeOut ),
0 commit comments