chore(node): cover the sync tick's online prune from the job package

The traffic sync's call that drops online sets of nodes it no longer
fetches had no test: a job-package test cannot install an xray process,
so online state was invisible there and removing the call passed.

SetXrayProcessForTest installs a test process for tests in other packages,
the same kind of seam as Manager.SetRuntimeOverride. The new job test runs
a real tick with a disabled node and a deleted one and fails without the
call.
This commit is contained in:
Sanaei
2026-09-15 20:39:32 +02:00
parent bc49c1a68f
commit d1c4e0261b
2 changed files with 61 additions and 0 deletions
@@ -0,0 +1,16 @@
package service
import "github.com/mhsanaei/3x-ui/v3/internal/xray"
// SetXrayProcessForTest installs p as the running process and returns the restore func,
// so tests in other packages can observe online state. Never call it in production.
func SetXrayProcessForTest(p *xray.Process) (restore func()) {
previousProcess, previousResult := xrayState.snapshot()
xrayState.replace(p)
return func() {
xrayState.mu.Lock()
xrayState.process = previousProcess
xrayState.result = previousResult
xrayState.mu.Unlock()
}
}