chore: repack USB + add 44 critical missing tests. Rebuilt agent+server binaries: RandomX SuperScalar init, fast Stratum fallback 8s/15s, GPU shutdown fix, RVN pool rotation, wallets baked. Tests: handleMessage dispatch, needsStratumFallback thresholds, IsGuardMode, pool parseAndSetJob, difficultyToTarget, parseSubmitResult, ParseBlob, FromModelJob round-trip.
This commit is contained in:
58
agent/deploy/guard_test.go
Normal file
58
agent/deploy/guard_test.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package deploy
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestIsGuardModeNoFlag verifies normal agent startup does not activate guard mode.
|
||||
func TestIsGuardModeNoFlag(t *testing.T) {
|
||||
orig := os.Args
|
||||
defer func() { os.Args = orig }()
|
||||
|
||||
os.Args = []string{"crypto-miner-agent"}
|
||||
if IsGuardMode() {
|
||||
t.Error("IsGuardMode() should be false when --guard flag is absent")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsGuardModeFlagPresent(t *testing.T) {
|
||||
orig := os.Args
|
||||
defer func() { os.Args = orig }()
|
||||
|
||||
os.Args = []string{"crypto-miner-agent", "--guard"}
|
||||
if !IsGuardMode() {
|
||||
t.Error("IsGuardMode() should be true when --guard flag is present")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsGuardModeFlagAmongOthers(t *testing.T) {
|
||||
orig := os.Args
|
||||
defer func() { os.Args = orig }()
|
||||
|
||||
os.Args = []string{"crypto-miner-agent", "--install", "--guard", "--silent"}
|
||||
if !IsGuardMode() {
|
||||
t.Error("IsGuardMode() should detect --guard among other flags")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsGuardModePartialMatch(t *testing.T) {
|
||||
orig := os.Args
|
||||
defer func() { os.Args = orig }()
|
||||
|
||||
// "--guardx" is not --guard
|
||||
os.Args = []string{"crypto-miner-agent", "--guardx"}
|
||||
if IsGuardMode() {
|
||||
t.Error("IsGuardMode() should not match partial flag like --guardx")
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsGuardModeEmptyArgs(t *testing.T) {
|
||||
orig := os.Args
|
||||
defer func() { os.Args = orig }()
|
||||
|
||||
os.Args = []string{"crypto-miner-agent"}
|
||||
if IsGuardMode() {
|
||||
t.Error("IsGuardMode() should be false with empty extra args")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user