mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-10 23:02:44 +02:00
chainntnfs+queue: move ConcurrentQueue to own package 'queue'
This commit is contained in:
26
queue/queue_test.go
Normal file
26
queue/queue_test.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package queue_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/lightningnetwork/lnd/queue"
|
||||
)
|
||||
|
||||
func TestConcurrentQueue(t *testing.T) {
|
||||
queue := queue.NewConcurrentQueue(100)
|
||||
queue.Start()
|
||||
defer queue.Stop()
|
||||
|
||||
// Pushes should never block for long.
|
||||
for i := 0; i < 1000; i++ {
|
||||
queue.ChanIn() <- i
|
||||
}
|
||||
|
||||
// Pops also should not block for long. Expect elements in FIFO order.
|
||||
for i := 0; i < 1000; i++ {
|
||||
item := <-queue.ChanOut()
|
||||
if i != item.(int) {
|
||||
t.Fatalf("Dequeued wrong value: expected %d, got %d", i, item.(int))
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user