@@ -312,9 +312,26 @@ func (c *autoloopTestCtx) autoloop(step *autoloopStep) {
312312 // Assert that we query the server for a quote for each of our
313313 // recommended swaps. Note that this differs from our set of expected
314314 // swaps because we may get quotes for suggested swaps but then just
315- // log them.
315+ // log them. The order in c.quoteRequestIn is not deterministic,
316+ // it depends on the order of map traversal (map peerChannels in
317+ // method Manager.SuggestSwaps). So receive from the channel an item
318+ // and then find a corresponding expected item, using amount as a key.
319+ amt2expected := make (map [btcutil.Amount ]quoteInRequestResp )
316320 for _ , expected := range step .quotesIn {
321+ // Make sure all amounts are unique.
322+ require .NotContains (c .t , amt2expected , expected .request .Amount )
323+
324+ amt2expected [expected .request .Amount ] = expected
325+ }
326+
327+ for i := 0 ; i < len (step .quotesIn ); i ++ {
317328 request := <- c .quoteRequestIn
329+
330+ // Get the expected item, using amount as a key.
331+ expected , has := amt2expected [request .Amount ]
332+ require .True (c .t , has )
333+ delete (amt2expected , request .Amount )
334+
318335 assert .Equal (
319336 c .t , expected .request .Amount , request .Amount ,
320337 )
0 commit comments