|
|
@ -1098,7 +1098,10 @@ func TestInFlightLimit(t *testing.T) {
|
|
|
|
name string
|
|
|
|
name string
|
|
|
|
maxInFlight int
|
|
|
|
maxInFlight int
|
|
|
|
existingSwaps []*loopdb.LoopOut
|
|
|
|
existingSwaps []*loopdb.LoopOut
|
|
|
|
suggestions *Suggestions
|
|
|
|
// peerRules will only be set (instead of test default values)
|
|
|
|
|
|
|
|
// is it is non-nil.
|
|
|
|
|
|
|
|
peerRules map[route.Vertex]*ThresholdRule
|
|
|
|
|
|
|
|
suggestions *Suggestions
|
|
|
|
}{
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "none in flight, extra space",
|
|
|
|
name: "none in flight, extra space",
|
|
|
@ -1175,6 +1178,31 @@ func TestInFlightLimit(t *testing.T) {
|
|
|
|
DisqualifiedPeers: noPeersDisqualified,
|
|
|
|
DisqualifiedPeers: noPeersDisqualified,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: "peer rules max swaps exceeded",
|
|
|
|
|
|
|
|
maxInFlight: 2,
|
|
|
|
|
|
|
|
existingSwaps: []*loopdb.LoopOut{
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Contract: autoOutContract,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
// Create two peer-level rules, both in need of a swap,
|
|
|
|
|
|
|
|
// but peer 1 needs a larger swap so will be
|
|
|
|
|
|
|
|
// prioritized.
|
|
|
|
|
|
|
|
peerRules: map[route.Vertex]*ThresholdRule{
|
|
|
|
|
|
|
|
peer1: NewThresholdRule(50, 0),
|
|
|
|
|
|
|
|
peer2: NewThresholdRule(40, 0),
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
suggestions: &Suggestions{
|
|
|
|
|
|
|
|
OutSwaps: []loop.OutRequest{
|
|
|
|
|
|
|
|
chan1Rec,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
DisqualifiedChans: noneDisqualified,
|
|
|
|
|
|
|
|
DisqualifiedPeers: map[route.Vertex]Reason{
|
|
|
|
|
|
|
|
peer2: ReasonInFlight,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, testCase := range tests {
|
|
|
|
for _, testCase := range tests {
|
|
|
@ -1191,10 +1219,17 @@ func TestInFlightLimit(t *testing.T) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
params := defaultParameters
|
|
|
|
params := defaultParameters
|
|
|
|
params.ChannelRules = map[lnwire.ShortChannelID]*ThresholdRule{
|
|
|
|
|
|
|
|
chanID1: chanRule,
|
|
|
|
if testCase.peerRules != nil {
|
|
|
|
chanID2: chanRule,
|
|
|
|
params.PeerRules = testCase.peerRules
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
params.ChannelRules =
|
|
|
|
|
|
|
|
map[lnwire.ShortChannelID]*ThresholdRule{
|
|
|
|
|
|
|
|
chanID1: chanRule,
|
|
|
|
|
|
|
|
chanID2: chanRule,
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
params.MaxAutoInFlight = testCase.maxInFlight
|
|
|
|
params.MaxAutoInFlight = testCase.maxInFlight
|
|
|
|
|
|
|
|
|
|
|
|
// By default we only have budget for one swap, increase
|
|
|
|
// By default we only have budget for one swap, increase
|
|
|
|