Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
When ai_control_enabled and mining interrupts or hashrate drops, the server composes same-agent fix plans (container restart, chain reorder, GPU swap, idle tune, RandomX restart) with Seer and oath ledger audit — no spread or lateral escalation.
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package ai
|
|
|
|
import "testing"
|
|
|
|
func TestExpandMiningSelfSurgeryUnwrapsActions(t *testing.T) {
|
|
out := ExpandMiningSelfSurgery(Command{
|
|
Type: CmdMiningSelfSurgery,
|
|
Args: map[string]interface{}{
|
|
"actions": []interface{}{"container_restart", "randomx_restart"},
|
|
},
|
|
})
|
|
if len(out) != 2 {
|
|
t.Fatalf("len=%d want 2", len(out))
|
|
}
|
|
if out[0].Type != CmdContainerRestart || out[1].Type != CmdRandomXRestart {
|
|
t.Fatalf("types=%v %v", out[0].Type, out[1].Type)
|
|
}
|
|
}
|
|
|
|
func TestFilterMiningSelfSurgeryCommandsDropsSpread(t *testing.T) {
|
|
cmds := FilterMiningSelfSurgeryCommands([]Command{
|
|
{Type: CmdDiscoverAndJoin},
|
|
{Type: CmdContainerRestart},
|
|
{Type: CmdSpreadNow},
|
|
{Type: CmdRandomXRestart},
|
|
})
|
|
if len(cmds) != 2 {
|
|
t.Fatalf("len=%d want 2", len(cmds))
|
|
}
|
|
if cmds[0].Type != CmdContainerRestart || cmds[1].Type != CmdRandomXRestart {
|
|
t.Fatalf("cmds=%v", cmds)
|
|
}
|
|
}
|
|
|
|
func TestIsForbiddenSpreadCommand(t *testing.T) {
|
|
if !IsForbiddenSpreadCommand("discover_and_join") {
|
|
t.Fatal("expected forbidden")
|
|
}
|
|
if IsForbiddenSpreadCommand("container_restart") {
|
|
t.Fatal("mining fix should not be forbidden")
|
|
}
|
|
}
|