@@ -1098,7 +1098,10 @@ func TestInFlightLimit(t *testing.T) {
10981098 name string
10991099 maxInFlight int
11001100 existingSwaps []* loopdb.LoopOut
1101- suggestions * Suggestions
1101+ // peerRules will only be set (instead of test default values)
1102+ // is it is non-nil.
1103+ peerRules map [route.Vertex ]* ThresholdRule
1104+ suggestions * Suggestions
11021105 }{
11031106 {
11041107 name : "none in flight, extra space" ,
@@ -1175,6 +1178,32 @@ func TestInFlightLimit(t *testing.T) {
11751178 DisqualifiedPeers : noPeersDisqualified ,
11761179 },
11771180 },
1181+ {
1182+ name : "peer rules max swaps exceeded" ,
1183+ maxInFlight : 2 ,
1184+ existingSwaps : []* loopdb.LoopOut {
1185+ {
1186+ Contract : autoOutContract ,
1187+ },
1188+ },
1189+ // Create two peer-level rules, both in need of a swap,
1190+ // but peer 1 needs a larger swap so will be
1191+ // prioritized.
1192+ peerRules : map [route.Vertex ]* ThresholdRule {
1193+ peer1 : NewThresholdRule (50 , 0 ),
1194+ peer2 : NewThresholdRule (40 , 0 ),
1195+ },
1196+ suggestions : & Suggestions {
1197+ OutSwaps : []loop.OutRequest {
1198+ chan1Rec ,
1199+ },
1200+ DisqualifiedChans : noneDisqualified ,
1201+ // This is a bug, we should list our second
1202+ // peer as disqualified because we've hit our
1203+ // in-flight limit for now.
1204+ DisqualifiedPeers : noPeersDisqualified ,
1205+ },
1206+ },
11781207 }
11791208
11801209 for _ , testCase := range tests {
@@ -1191,10 +1220,17 @@ func TestInFlightLimit(t *testing.T) {
11911220 }
11921221
11931222 params := defaultParameters
1194- params .ChannelRules = map [lnwire.ShortChannelID ]* ThresholdRule {
1195- chanID1 : chanRule ,
1196- chanID2 : chanRule ,
1223+
1224+ if testCase .peerRules != nil {
1225+ params .PeerRules = testCase .peerRules
1226+ } else {
1227+ params .ChannelRules =
1228+ map [lnwire.ShortChannelID ]* ThresholdRule {
1229+ chanID1 : chanRule ,
1230+ chanID2 : chanRule ,
1231+ }
11971232 }
1233+
11981234 params .MaxAutoInFlight = testCase .maxInFlight
11991235
12001236 // By default we only have budget for one swap, increase
0 commit comments