mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-11 00:32:38 +02:00
htlcswitch: expand TestWaitingQueueThreadSafety to assert proper queue length
This commit is contained in:
@@ -29,6 +29,14 @@ func TestWaitingQueueThreadSafety(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
// The reported length of the queue should be the exact number of
|
||||
// packets we added above.
|
||||
queueLength := q.Length()
|
||||
if queueLength != numPkts {
|
||||
t.Fatalf("queue has wrong length: expected %v, got %v", numPkts,
|
||||
queueLength)
|
||||
}
|
||||
|
||||
var b []lnwire.MilliSatoshi
|
||||
for i := 0; i < numPkts; i++ {
|
||||
q.SignalFreeSlot()
|
||||
@@ -42,6 +50,14 @@ func TestWaitingQueueThreadSafety(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// The length of the queue should be zero at this point.
|
||||
time.Sleep(time.Millisecond * 50)
|
||||
queueLength = q.Length()
|
||||
if queueLength != 0 {
|
||||
t.Fatalf("queue has wrong length: expected %v, got %v", 0,
|
||||
queueLength)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(b, a) {
|
||||
t.Fatal("wrong order of the objects")
|
||||
}
|
||||
|
Reference in New Issue
Block a user