Builder and Settings expose install base/subfolder with live preview. Agent embeds on first exe run to the configured path, pauses for idle CPU and scheduled windows, and reports real system CPU usage.
32 lines
802 B
Go
32 lines
802 B
Go
package miner
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"crypto-miner-agent/config"
|
|
"crypto-miner-agent/stats"
|
|
)
|
|
|
|
func parseTestTime(hour, minute int) time.Time {
|
|
return time.Date(2026, 5, 26, hour, minute, 0, 0, time.UTC)
|
|
}
|
|
|
|
func TestScheduleGuardAlways(t *testing.T) {
|
|
guard := NewScheduleGuard(config.RuntimeConfig{BuiltinConfig: config.BuiltinConfig{MiningMode: "always"}}, stats.NewReporter())
|
|
if !guard.Allowed() {
|
|
t.Fatal("always mode should allow mining")
|
|
}
|
|
}
|
|
|
|
func TestScheduleGuardScheduledUsesConfigWindow(t *testing.T) {
|
|
cfg := config.RuntimeConfig{BuiltinConfig: config.BuiltinConfig{
|
|
MiningMode: "scheduled",
|
|
ScheduleStart: "21:00",
|
|
ScheduleEnd: "06:00",
|
|
}}
|
|
if !cfg.InScheduleWindow(parseTestTime(23, 0)) {
|
|
t.Fatal("expected overnight schedule to allow mining at 23:00")
|
|
}
|
|
}
|