diff --git a/blockchain/v2/routine.go b/blockchain/v2/routine.go index eaaa68cf0..9c5b97b18 100644 --- a/blockchain/v2/routine.go +++ b/blockchain/v2/routine.go @@ -23,12 +23,12 @@ type handleFunc = func(event Event) (Event, error) // sent events and produce `last()` event representing the terminal state. type Routine struct { name string + handle handleFunc queue *queue.PriorityQueue - out chan Event // XXX: actually item + out chan Event fin chan error rdy chan struct{} running *uint32 - handle handleFunc logger log.Logger metrics *Metrics } @@ -38,8 +38,8 @@ var queueSize int = 10 func newRoutine(name string, handleFunc handleFunc) *Routine { return &Routine{ name: name, - queue: queue.NewPriorityQueue(queueSize, true), handle: handleFunc, + queue: queue.NewPriorityQueue(queueSize, true), out: make(chan Event, queueSize), rdy: make(chan struct{}, 1), fin: make(chan error, 1), diff --git a/blockchain/v2/routine_test.go b/blockchain/v2/routine_test.go index 38bff1fcf..6fa8bde32 100644 --- a/blockchain/v2/routine_test.go +++ b/blockchain/v2/routine_test.go @@ -143,8 +143,12 @@ func TestPriority(t *testing.T) { }() time.Sleep(10 * time.Millisecond) + assert.True(t, routine.isRunning(), + "expected an started routine") assert.True(t, routine.trySend(highPriorityEvent{}), "expected send to succeed even when saturated") assert.Equal(t, done, <-routine.final()) + assert.False(t, routine.isRunning(), + "expected an started routine") }