Files
Alex Jbanca af464bad6c feat: make system/app services pausable (#7391)
* feat: make system/app services pausable

Embed PauseBroadcaster and implement Pausable in wallet, connector,
newsfeed, ipfs downloader, NTP time source, and RPC rate limiter.

Each service registers itself via service_pausable.go. Goroutine loops
use PausableTicker or Subscription.C() to block while paused, reducing
non-essential background work.

* chore: lint test files
2026-04-09 09:58:17 +03:00

39 lines
790 B
Go

package ipfs
import (
"testing"
"time"
"github.com/stretchr/testify/require"
)
func TestTaskDispatcherPausesAndResumesByLifecycle(t *testing.T) {
d := &Downloader{
inputTaskChan: make(chan taskRequest, 1),
rateLimiterChan: make(chan taskRequest, 1),
quit: make(chan struct{}, 1),
}
d.MarkPaused()
go d.taskDispatcher()
defer close(d.quit)
req := taskRequest{cid: "cid-1", doneChan: make(chan taskResponse, 1)}
d.inputTaskChan <- req
select {
case <-d.rateLimiterChan:
t.Fatal("task was dispatched while paused")
case <-time.After(450 * time.Millisecond):
}
d.MarkResumed()
select {
case got := <-d.rateLimiterChan:
require.Equal(t, req.cid, got.cid)
case <-time.After(2 * time.Second):
t.Fatal("task was not dispatched after resume")
}
}