utxonursery: use mocked sweeper in tests

This commit fixes a test flake caused by a race condition. Using the
real sweeper in the nursery test created too complex concurrent
behaviour to reliably assert on and made the tests difficult to
comprehend.
This commit is contained in:
Joost Jager committed 2018-12-19 14:14:53 +01:00
1 parent e29b0f8894
commit 347d1545de
2 files changed
+13 -79

No files matched your search

+2 -4
View File
@@ -2,8 +2,6 @@ package sweep
import (
"fmt"
"os"
"runtime/pprof"
"sync"
"testing"
"time"
@@ -58,6 +56,8 @@ func NewMockNotifier(t *testing.T) *MockNotifier {
// NotifyEpoch simulates a new epoch arriving.
func (m *MockNotifier) NotifyEpoch(height int32) {
m.t.Helper()
for epochChan, chanHeight := range m.epochChan {
// Only send notifications if the height is greater than the
// height the caller passed into the register call.
@@ -72,8 +72,6 @@ func (m *MockNotifier) NotifyEpoch(height int32) {
Height: height,
}:
case <-time.After(defaultTestTimeout):
pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
m.t.Fatal("epoch event not consumed")
}
}